-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.php
executable file
·70 lines (44 loc) · 1.54 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 include('includes/fancyheader.php'); ?>
<?php
include('connection.php');
$errors = "";
if(isset($_POST["log_submit"])){
$username = $_POST["log_username"];
$password = $_POST["log_password"];
if(!empty($username) && !empty($password)){
$username = mysqli_real_escape_string($connect,$username);
$password = md5($password);
$query = mysqli_query($connect,"SELECT id FROM user WHERE email='$username' AND password='$password'");
$rows = mysqli_num_rows($query);
if($rows == 1){
$data = mysqli_fetch_array($query);
$uid = $data["id"];
$_SESSION["userid"] = $uid;
header("Location: dashboard.php");
} else {
$errors = "Incorrect username/password";
}
} else {
$errors = "Username and password cannot be empty!";
}
}
?>
<div class="centerboxsmall" style="height: 265px;">
<img src="img/logo.png" style="width: 300px;"/>
<form action="#" method="post">
<input placeholder="Username" required type="email" class="form-control" name="log_username"/>
<input placeholder="Password" required type="password" class="form-control" name="log_password"/>
<input value="SIGN IN" type="submit" class="btn btn-warning" name="log_submit"/>
<a href="register.php">Don't have an account? SignUp</a>
<?php
if(!empty($errors)){
?>
<div class="alert alert-danger" role="alert">
<?php echo $errors ?>
</div>
<?php
}
?>
</form>
</div>
<?php include('includes/fancyfooter.php'); ?>