-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathindex.php
87 lines (81 loc) · 2.12 KB
/
index.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
<?php
$con = new PDO('mysql:host=127.0.0.1;dbname=sql_injection', 'root', '');
if (isset($_POST['submit'])) {
$name = trim($_POST['name']);
$password = trim($_POST['password']);
$userQuery = $con->prepare("SELECT * FROM users WHERE name = :name");
$userQuery->execute(['name' => $name]);
$user = $userQuery->fetch(PDO::FETCH_OBJ);
$db_password = $user->password;
if (password_verify($password, $db_password)) {
echo "<p class='bg-success'>User verified</p>";
} else {
echo "<p class='bg-danger'> User not verified</p>";
}
// $insertQuery = $con->prepare("INSERT INTO users(name, email, password) VALUES(:name, :email, :password) ");
//
// $insertQuery->execute([
//
// 'name'=> $name,
// 'email'=> 'edwin@codingfaculty.com',
// 'password'=> password_hash($password, PASSWORD_BCRYPT, [12])
//
//
// ]);
//
//
//
// $userQuery = $con->prepare("SELECT * FROM users WHERE name = :name ");
//
//
//
//
// $userQuery->execute([
//
//
// 'name'=> $name
//
//
//
// ]);
//
//
//
//
//
// if($userQuery->rowCount()){
//
// echo "WE FOUND A USER";
//
//
// }
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
</head>
<body>
<div class="col-sm-6 col-sm-offset-4">
<form action="" method="post" autocomplete="off">
<h2>Login</h2>
<div class="form-group">
<label for="name">
Name
<input type="text" name="name" class="form-control">
</label>
</div>
<div class="form-group">
<label for="password">
Password
<input type="text" name="password" class="form-control">
</label>
</div>
<input type="submit" name="submit" class="btn btn-primary">
</form>
</div>
</body>
</html>