-
Notifications
You must be signed in to change notification settings - Fork 33
/
login.php
75 lines (55 loc) · 1.67 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
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
session_start();
if(isset($_SESSION['uid']))
{
header('location:admin/admindash.php');
}
?>
<html lang="en_US">
<head>
<meta charset ="UTF-8">
<title> Admin Login </title>
</head>
<body>
<h1 align="center">Admin Login</h1><br>
<form action="login.php" method="post">
<table align="center">
<tr>
<td>Username</td><td><input type="text" name="uname"></td>
</tr>
<tr>
<td>Password</td><td><input type="password" name="pass"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="login" value="Login"></td>
</tr>
</table>
</form>
</body>
</html>
<?php
include('dbcon.php');
if(isset($_POST['login'])){
$username = mysqli_real_escape_string($con,$_POST['uname']);
$password = mysqli_real_escape_string($con,$_POST['pass']);
$qry = "SELECT * FROM `admin` WHERE `username` = '$username' AND `password` = '$password'";
$run = mysqli_query($con,$qry);
$row = mysqli_num_rows($run);
if($row>=1)
{
$data = mysqli_fetch_assoc($run);
$id = $data['id'];
$_SESSION['uid']=$id;
header('location:admin/admindash.php');
}
else
{
?>
<script>
alert('Username Or Password Dont match');
window.open('login.php','_self')
</script>
<?php
}
}
?>