-
Notifications
You must be signed in to change notification settings - Fork 0
/
test2.php
40 lines (32 loc) · 1.18 KB
/
test2.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
<?php
session_start();
$db = mysqli_connect("localhost", "root", "", "first_db");
//$_SESSION['id'] = 1;
if(isset($_POST['submit'])){
$email = mysqli_real_escape_string($db,$_POST['email']);
$_SESSION['var'] = $email;
$password = mysqli_real_escape_string($db,$_POST['password']);
$confirmPassword = mysqli_real_escape_string($db,$_POST['cpassword']);
if($password==$confirmPassword){
$sql = "SELECT * FROM users where email='$email';";
$results= mysqli_query($db,$sql);
$resultsCheck = mysqli_num_rows($results);
if($resultsCheck>0){
while($row = mysqli_fetch_assoc($results)){
$pass = $row['password'];
$passwordHashDb = password_hash($pass,PASSWORD_DEFAULT); //dehashinhg
if(password_verify($password, $passwordHashDb) ==true){
echo "hi";
header('Location:index.php?login=success');
}else{
echo "Wrong Password! ";
}
}
}else{
echo "The user registered with this email not found!";
}
}else{
echo "The 2 passwords do not match";
}
}
?>