ЁЯУБ File Manager
Editing:
/home/wvl7mof7402e/www/chemtechieg.com/admin/user_video_access.php
<?php require("top.php"); $msg = ""; // рдЬрдм рдлреЙрд░реНрдо рд╕рдмрдорд┐рдЯ рд╣реЛ рддреЛ if (isset($_POST['submit'])) { $course_title_id = mysqli_real_escape_string($con, $_POST['course_title_id']); $video_title = mysqli_real_escape_string($con, $_POST['video_title']); $video_link = mysqli_real_escape_string($con, $_POST['video_link']); // Validate URL if (!filter_var($video_link, FILTER_VALIDATE_URL)) { $msg = "Invalid video link."; } if ($msg == '') { // Check if video title exists $res = mysqli_query($con, "SELECT * FROM course_video WHERE video_title = '$video_title' AND course_title_id = '$course_title_id'"); $check = mysqli_num_rows($res); if ($check > 0) { if (isset($_GET['id']) && $_GET['id'] != '') { $getData = mysqli_fetch_assoc($res); if ($id != $getData['id']) { $msg = "Title already exists in this course."; } } else { $msg = "Title already exists in this course."; } } // Insert or Update Video if ($msg == '') { if (isset($_GET['id']) && $_GET['id'] != '') { // Existing video update mysqli_query($con, "UPDATE course_video SET video_title='$video_title', video_link='$video_link' WHERE id='$id'"); } else { // Insert new video mysqli_query($con, "INSERT INTO course_video(course_title_id, video_title, video_link, status) VALUES('$course_title_id', '$video_title', '$video_link', 1)"); // Get last inserted video ID $video_id = mysqli_insert_id($con); // Give access to all users $users_res = mysqli_query($con, "SELECT id FROM users WHERE status = 1"); while ($user = mysqli_fetch_assoc($users_res)) { $user_id = $user['id']; mysqli_query($con, "INSERT INTO user_video_access (user_id, video_id) VALUES ('$user_id', '$video_id')"); } } header("Location: course_video.php"); die(); } } } ?>
Save
Cancel