-
Notifications
You must be signed in to change notification settings - Fork 1
/
login.php
94 lines (83 loc) · 3.75 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
94
<?php
session_start();
include "connection.php";
if (isset($_POST['loginbtn'])) {
$email = $_POST['email'];
$password = $_POST['password'];
$userexists = false;
$query = "SELECT * FROM customer WHERE email = '$email' AND password = '$password' ";
$check_user_query = mysqli_query($connection, $query);
if (mysqli_num_rows($check_user_query) > 0) {
$userexists = true;
while ($row = mysqli_fetch_array($check_user_query)) {
$db_id = $row['id'];
$db_name = $row['name'];
$db_surname = $row['surname'];
$db_email = $row['email'];
$db_password = $row['password'];
$db_contact_info = $row['contact_info'];
$db_address = $row['address'];
}
}
if ($userexists) {
$_SESSION['id'] = $db_id;
$_SESSION['name'] = $db_name;
$_SESSION['surname'] = $db_surname;
$_SESSION['email'] = $db_email;
$_SESSION['password'] = $db_password;
$_SESSION['contact_info'] = $db_contact_info;
$_SESSION['address'] = $db_address;
header("Location: index.php");
echo '<div class="alert alert-success">Login Success!</div>';
} else {
echo '<div class="alert alert-danger">Invalid Credentials!</div>';
}
}
?>
<?php
if (isset($_SESSION['email'])) {
echo $_SESSION['name'];
}
?>
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">
<title>Login - Admin Panel</title>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-sm-4"></div>
<div class="col-sm-4">
<br><br><br><br><br><br><br><br>
<!-- <?php if ($LoginFail) {
echo '<div class="alert alert-danger">Invalid Credentials.</div>';
} ?> -->
<div class="card text-dark bg-light mb-3">
<div class="card-header"><b>User Login</b></div>
<div class="card-body">
<form action="" method="POST">
<div class="input-group mb-3">
<span class="input-group-text bg-light" id="inputGroup-sizing-default">Email </span>
<input required type="email" class="form-control" name="email" aria-label="Sizing example input" aria-describedby="inputGroup-sizing-default">
</div>
<div class="input-group mb-3">
<span class="input-group-text bg-light" id="inputGroup-sizing-default">Password</span>
<input required type="password" class="form-control" name="password" aria-label="Sizing example input" aria-describedby="inputGroup-sizing-default">
</div>
<input type="submit" class="btn btn-success" name="loginbtn" value="Login">
</form>
</div>
</div>
</div>
<div class="col-sm-4"></div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-gtEjrD/SeCtmISkJkNUaaKMoLD0//ElJ19smozuHV6z3Iehds+3Ulb9Bn9Plx0x4" crossorigin="anonymous"></script>
</body>
</html>