-
Notifications
You must be signed in to change notification settings - Fork 0
/
addexams.php
35 lines (26 loc) · 858 Bytes
/
addexams.php
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
29
30
31
32
33
34
35
<?php
$sname = "localhost";
$uname = "root";
$pass = "";
$dbname = "dmw_cw";
$conn = mysqli_connect($sname, $uname, $pass, $dbname);
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$exam_name = $_POST['Module'];
$exam_date = $_POST['exam-date'];
$exam_time = $_POST['exam-time'];
$sql = "INSERT INTO exam (ExamName, ExamDate, ExamTime) VALUES ('$exam_name', '$exam_date', '$exam_time')";
if (mysqli_query($conn, $sql))
{
echo "<script>alert('add successs, redirecting to the view page...');</script>";
echo "<script>window.location.href = 'viewexams2.php';</script>";
}
else
{
echo "<script>alert('Error: Cannot insert exam');</script>";
}
}
mysqli_close($conn);
?>