-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
75 lines (68 loc) · 1.92 KB
/
index.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
<?php
session_start();
require_once('dbconfig/config.php');
//phpinfo();
?>
<!DOCTYPE html>
<html>
<head>
<title>Login Page</title>
<link rel="stylesheet" href="css/style2.css">
</head>
<body style="background-color:#bdc3c7">
<div id="main-wrapper">
<center><h2>Login to Your Account</h2></center>
<div class="imgcontainer">
<img src="imgs/football.jpg" alt="Avatar" class="avatar">
</div>
<form action="index.php" method="post">
<div class="inner_container">
<label><b>Username</b></label>
<input type="text" placeholder="Enter Username" name="username" required>
<label><b>Password</b></label>
<input type="password" placeholder="Enter Password" name="password" required>
<button class="login_button" name="login" type="submit">Login</button>
<a href="register.php"><button type="button" class="register_btn">Register</button></a>
</div>
</form>
<?php
if(isset($_POST['login']))
{
@$username=$_POST['username'];
@$password=$_POST['password'];
$query = "select * from users where username='$username' and password='$password' ";
//echo $query;
$query_run = mysqli_query($con,$query);
//echo mysql_num_rows($query_run);
if($query_run)
{
if(mysqli_num_rows($query_run)>0)
{
$row = mysqli_fetch_array($query_run,MYSQLI_ASSOC);
$_SESSION['username'] = $username;
$_SESSION['password'] = $password;
if($_SESSION['username'] == 'admin')
{
header("Location: admin_homepage.php");
}
else {
header("Location: homepage.php");
}
}
else
{
echo '<script type="text/javascript">alert("No such User exists. Invalid Credentials")</script>';
}
}
else
{
echo '<script type="text/javascript">alert("Database Error")</script>';
}
}
else
{
}
?>
</div>
</body>
</html>