D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
markniuj
/
bazmeasar.com
/
admin
/
Filename :
submit_video.php
back
Copy
<?php include "../config.php"; ?> <?php // Check if the form was submitted if ($_SERVER["REQUEST_METHOD"] == "POST") { // Get form data $vedio_name = $_POST["vedio_name"]; $vedio_link = $_POST["vedio_link"]; $vedio_category = $_POST["vedio_category"]; $description = $_POST["description"]; $vedio_date = $_POST["vedio_date"]; // Handle file upload for video image if ($_FILES["vedio_img"]["error"] == UPLOAD_ERR_OK) { $target_dir = "uploads/video_img/"; // Specify your target directory $target_file = $target_dir . basename($_FILES["vedio_img"]["name"]); $uploaded = move_uploaded_file($_FILES["vedio_img"]["tmp_name"], $target_file); if ($uploaded) { // Get just the file name $file_name = basename($_FILES["vedio_img"]["name"]); // The file was uploaded successfully, you can proceed to insert data into the database // Make sure to validate and sanitize user inputs before inserting into the database to prevent SQL injection. $sql = "INSERT INTO videos (vedio_name, vedio_link, vedio_category, vedio_img, description, vedio_date) VALUES ('$vedio_name', '$vedio_link', '$vedio_category', '$file_name', '$description', '$vedio_date')"; if ($conn->query($sql) === TRUE) { echo "Video submitted successfully!<br><a href='add_videos.php'>Go back to home</a>"; } else { echo "Error: " . $sql . "<br>" . $conn->error; } } else { echo "File upload failed. Please check your server's configuration."; } } else { echo "Error uploading the video image. Make sure you selected a valid image file."; } // Close the database connection $conn->close(); } else { // If the form was not submitted, redirect to the form page header("Location: add_video.php"); exit(); } ?>