forked from Git21221/IBMSkillsBuild
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathotp.php
39 lines (36 loc) · 1.13 KB
/
otp.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
<?php
include_once 'db.php';
session_start();
$otp1= $_POST['otp1'];
$otp2= $_POST['otp2'];
$otp3= $_POST['otp3'];
$otp4= $_POST['otp4'];
$unique_id = $_SESSION['unique_id'];
$sql = mysqli_query($conn, "SELECT * FROM users WHERE unique_id ='{$unique_id}'");
$row = mysqli_fetch_assoc($sql);
$session_otp = $row['otp'];
$otp = $otp1.$otp2.$otp3.$otp4;
if(!empty($otp)){
if($otp == $session_otp){
$sql = mysqli_query($conn, "SELECT * FROM elitte WHERE unique_id ='{$unique_id}' AND otp = '{$otp}'");
if(mysqli_num_rows($sql)>0){
$null_otp = 0;
$sql2 = mysqli_query($conn,"UPDATE elitte SET `verification_status`= 'Verified',`otp`='$null_otp' WHERE $unique_id ='{$unique_id}'");
if($sql2){
$row = mysqli_fetch_assoc($sql);
if($row){
$_SESSION['unique_id'] = $row['unique_id'];
$_SESSION['verification_status']=$row['verification_status'];
echo 'Success';
}
}
}
}
else{
echo "Wrong Otp!";
}
}
else{
echo "Enter Otp!";
}
?>