-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_teacher.php
86 lines (66 loc) · 1.93 KB
/
check_teacher.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
// Create a connection
$conn=mysqli_connect("localhost","root","","dbw");
if(!$conn){
die("Connection not Successfull!");
}
//print "Connection Created Succesfully! <br>";
// Retrieve user input
$tuser_id = $_POST['tuser_id'];
$tpassword = $_POST['tpassword'];
session_start();
$_SESSION['$avi'] = $tuser_id;
// SQL query to check if the credentials are valid
$sql = "SELECT * FROM teacher WHERE tuser_id = '$tuser_id' AND tpass = '$tpassword'";
$result = mysqli_query($conn,$sql);
if (mysqli_num_rows($result) > 0) {
echo "Sign-in Successful!";
} else {
echo '<script>alert("Invalid credentials.");</script>';
echo '<script>
setTimeout(function() {
window.location.href = "teacher_signin.html";
}, 1000); // Delay in milliseconds (e.g., 1000 = 1 second)
</script>';
//header("Location: student_signin.html");
exit(); // Ensure that no further code is executed after the redirect
}
// Close the connection
mysqli_close($conn);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Your Page Title</title>
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
margin: 20px;
}
button {
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
background-color: #4CAF50;
color: #fff;
border: none;
border-radius: 5px;
margin: 5px;
}
button:hover {
background-color: #45a049;
}
</style>
</head>
<body>
<form action="course_teach.php" method="get">
<button type="submit">continue</button>
</form>
<form action="home.html" method="get">
<button type="submit">LOGOUT</button>
</form>
</body>
</html>