-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path37.PasswordEncryption.php
50 lines (35 loc) · 1.36 KB
/
37.PasswordEncryption.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
<?php include "36.PhpInclude/db.php";
if(isset($_POST['submit'])) {
$userName = $_POST['username'];
$password = $_POST['password'];
$userName = mysqli_real_escape_string($connection , $userName);
$password = mysqli_real_escape_string($connection , $password);
$hashFormat = "$2y$10$";
$salt = $hashFormat."AnyStringOfLengthMoreThan22CanBeUsed";
$encryptedPassword = crypt($password, $salt);
$query = "insert into users(username,password) values('$userName','$encryptedPassword')";
$result = mysqli_query($connection, $query);
if(!$result)
die("Query failed<br/>". mysqli_error($connection));
else
echo "Query Executed Successfully<br/>";
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<form action = "37.PasswordEncryption.php" method="post">
<pre>
<input type="text" placeholder = "Enter username" name="username" />
<input type="password" placeholder = "Enter Passwrod" name="password" />
<input type="submit" value="SignUp" name="submit"/>
</pre>
</form>
</body>
</html>