-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddLessonbts.php
More file actions
28 lines (23 loc) · 1.06 KB
/
addLessonbts.php
File metadata and controls
28 lines (23 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
include "sql_lesson_conn.php";
$id = $status = $fno = "";
if($_SERVER["REQUEST_METHOD"] == "POST"){
$id = trim($_POST["lessonid"]);
$lname = trim($_POST["lname"]);
$link = trim($_POST["link"]);
$query = mysqli_query($conn, "SELECT * FROM LESSONS WHERE LID = '$id'");
if(mysqli_num_rows($query) == 0){
mysqli_query($conn, "INSERT INTO LESSONS VALUES ('$id','$lname', '$link'); ");
$query = mysqli_query($conn, "SELECT * FROM LESSONS WHERE LID = '$id';" );
if(mysqli_num_rows($query) == 1){
echo '<script> alert("Lesson Added Successfully!!"); window.location.href = "./addLesson.php";</script>';
}
else{
echo '<script> alert("Unsuccessful Addition!"); window.location.href = "./addLesson.php";</script>';
}
}
else{
echo '<script> alert("The ID '.$id.' already exists. Enter a different Lesson ID."); window.location.href = "./addLesson.php";</script>';
}
}
?>