-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.php
61 lines (45 loc) · 1.59 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
<?php
include 'config.php';
session_start();
if (isset($_POST['submit'])) {
$email = mysqli_real_escape_string($conn, $_POST['email']);
$pass = mysqli_real_escape_string($conn, md5($_POST['password']));
$select = mysqli_query($conn, "SELECT * FROM `user_info` WHERE email = '$email' AND password = '$pass'") or die(mysqli_error($conn));
if (mysqli_num_rows($select) > 0) {
$row = mysqli_fetch_assoc($select);
$_SESSION['user_id'] = $row['id'];
header('location:index.php');
} else {
$message[] = 'Incorrect Password or Email!';
}
}
?>
<!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 | Mobile Store</title>
<link rel="stylesheet" href="css/style.css">
<link rel="shortcut icon" href="images/favicon.png" type="image/x-icon">
</head>
<body>
<?php
if (isset($message)) {
foreach ($message as $message) {
echo '<div class="message" onclick="this.remove();">' . $message . '</div>';
}
}
?>
<div class="form-container">
<form action="" method="post">
<h3>login now</h3>
<input type="email" name="email" required placeholder="Enter Email" class="box">
<input type="password" name="password" required placeholder="Enter Password" class="box">
<input type="submit" name="submit" class="btn" value="login now">
<p>Don't have an Account? <a href="register.php">Register Now</a></p>
</form>
</div>
</body>
</html>