-
Notifications
You must be signed in to change notification settings - Fork 1
/
adminafterlogin.php
38 lines (35 loc) · 1.15 KB
/
adminafterlogin.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
<?php
$servername = "localhost";
$username = "root";
$password = ""; //Enter your MySQL password here
$dbname = "hospitaldbms"; //Enter the name of the database, which in this case is 'hospitaldbms'
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
//Check connection
if ($conn->connect_error)
die("Connection failed: " . $conn->connect_error);
$username = $_POST["adminusername"];
$password = $_POST["adminpassword"];
$query = "SELECT * FROM adminlogin WHERE username = '".$username."' AND password = '".$password."';";
$result = $conn->query($query);
if($result->num_rows > 0)
{
while($row = $result->fetch_assoc())
{
$dbusername = $row["username"];
$dbpassword = $row["password"];
}
}
else
{
echo "<script>
alert('Invalid Username and Password. Please re-enter.');
document.location = 'adminlogin.html';
</script>";
}
if($username == $dbusername && $password == $dbpassword)
{
// Redirect browser
header("Location: adminhomepage.php");
}
?>