-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.php
70 lines (50 loc) · 1.84 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
<?php
session_start();
if(isset($_SESSION['usertype'])){
header("location: index.php");
}
elseif(isset($_POST['login'])){
require_once('inc/config.php');
$username=$_POST['userName'];
$password=$_POST['password'];
$password=md5($password);
$query="SELECT * FROM users WHERE username='$username' AND password='$password' LIMIT 1";
//echo $query;
$userquery=mysqli_query($connection,$query);
if(mysqli_num_rows($userquery)>0){
$userlogin = mysqli_fetch_array($userquery,MYSQLI_ASSOC);
$_SESSION['usertype']=$userlogin["type"];
$_SESSION['userid']=$userlogin["user_id"];
if($userlogin["type"]==1){
header("location: adminpanel.php");
}
else{
header("location: index.php");
}
}else{
echo "<script>alert('username or email invalied!')</script>";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Log In</title>
<link rel="stylesheet" type="text/css" href="./css/login.css ">
</head>
<body>
<div class="page"><br><br><br><br><br>
<div class="login">
<form action="login.php" autocomplete="on" method="POST"><!--autocomplete completes the input values based on values that the user has entered before -->
<br><br><br><br><lable id="formname" style="color: green">EXTARVAGANCE</lable>
<input type="text" name="userName" placeholder="Enter your name" required><br>
<input type="password" name="password" placeholder="Enter your password" required><br>
<input style="margin-left: 150px;margin-top: 50px;" type="submit" value="Log In" name="login"><br>
</form>
</div>
<div class="dont">
<lable id="signup">Don't you have a account? <a href="./register.php">Sign Up Now</a></lable>
</div>
</div>
</body>
</html>