-
Notifications
You must be signed in to change notification settings - Fork 1
/
login.php
62 lines (55 loc) · 1.19 KB
/
login.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
<?php
session_start();
if(isset($_SESSION['uid'])){
header('location:admin/admindash.php');
}
?>
<html>
<head>
<title>Admin Panel</title>
</head>
<body>
<h1 align="center">Admin Login</h1>
<form method="post" action=login.php>
<table align="center">
<tr>
<td>Username</td><td><input type="text" name="uname" required></td>
</tr>
<tr>
<td>Password</td><td><input type="Password" name="pass" required></td>
</tr>
<tr>
<td><input type="submit" name="login" value="Login"></td>
</tr>
</table>
</form>
</body>
</html>
<?php
include('dbcon.php');
if(isset($_POST['login'])){
$username=$_POST['uname'];
$password=$_POST['pass'];
echo "".$username;
echo "".$password;
$query="select * from admin where username = '$username' and password = '$password';";
$run=mysqli_query($con,$query);
$row=mysqli_num_rows($run);
echo $row;
if($row<1){
?>
<script>alert('Username or Password does not match !!')</script>
<script>window.open('login.php','_self')</script>
<?php
}
else{
$data=mysqli_fetch_assoc($run);
$id=$data['id'];
echo "id".$id;
session_start();
$_SESSION['uid']=$id;
echo "".$_SESSION['uid'];
header('location:admin/admindash.php');
}
}
?>