-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.php
93 lines (68 loc) · 2.45 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
@include 'connect.php';
if(isset($_POST['submit'])){
$name = mysqli_real_escape_string($con,$_POST['name']);
$email = mysqli_real_escape_string($con,$_POST['email']);
$pass = md5($_POST['password']);
$cpass = md5($_POST['cpassword']);
$user_type = $_POST['user_type'];
$select = " SELECT * FROM user WHERE email = '$email' && password = '$pass'";
$result = mysqli_query($con, $select);
if(mysqli_num_rows($result) > 0){
$row = mysqli_fetch_array($result);
if($row['user_type'] == 'admin'){
$_SESSION['admin_name'] = $row['name'];
header('location:admin.php');
}elseif($row['user_type'] == 'user'){
$_SESSION['user_name'] = $row['name'];
header('location:index.php');
}
}else{
$error[] = 'incorrect email or password!';
}
};
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login Form</title>
<!-- custom css file link -->
<link rel="stylesheet" href="./CSS/style.css">
</head>
<body>
<!--header design-->
<nav>
<input type="checkbox" id="check">
<label for="check" class="checkbtn">
<i class="fas fa-bars"></i>
</label>
<label class="logo">Applex</label>
<ul>
<li><a href="index.php">Home</a></li>
<li><a class="active" href="login.php">Login</a></li>
<li><a href="register.php">Register</a></li>
</ul>
</nav>
<!-- form design -->
<div class="form-container">
<form action="" method="post">
<h3>login now</h3>
<?php
if(isset($error)){
foreach($error as $error){
echo '<span class="error-msg">'.$error.'</span>';
};
};
?>
<input type="email" name="email" required placeholder="Enter your email">
<input type="password" name="password" required placeholder="Enter your password">
<input type="submit" name="submit" value="login now" class="form-btn">
<p>Don't have an account? <a href="register.php">Register now</a></p>
</form>
</div>
<?php include('footer.php') ?>
</body>
</html>