-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck.php
More file actions
44 lines (44 loc) · 1015 Bytes
/
check.php
File metadata and controls
44 lines (44 loc) · 1015 Bytes
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
<?php
//checks teacher session matches to the database
session_start();
if(!isset($_SESSION['spiusername'])){
die(header("location:index.php"));
}
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "SPI";
// Create connection
$conn = new mysqli($servername, $username, $password,$dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT username,password FROM Staff";
$result = $conn->query($sql);
$user= $_SESSION['spiusername'];
$pass= $_SESSION['spipassword'];
if ($result==true && $result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()){
if($row["username"]==$user){
if($row["password"]==$pass){
$c=True;
break;
}//p if
else{
$c=False;
}
}//u if
else{
$c=False;
}
}//wh
if($c==False){
if(session_destroy()) {
die(header("Location:index.php"));
}//if
}//if
}//res
$conn->close();
?>