-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathotpforgotpassStu.php
54 lines (51 loc) · 1.43 KB
/
otpforgotpassStu.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
<!DOCTYPE html>
<html>
<body>
<?php
session_start();
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$_SESSION["otp"]=test_input($_POST["otp"]);
$otp=$_SESSION["otp"];
$time= $_SESSION['date_clicked'];
$otp_sent=$_SESSION["otp_sent"];
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "classroom";
// $first = $_SESSION["firstname"];
// $last = $_SESSION["lastname"];
$email = $_SESSION["email"];
// $pass = $_SESSION["password"];
if(isset($_POST['check'])){
$time_clicked = date('Y-m-d H:i:s');
$_SESSION['time_clicked'] = $time_clicked;
//header("Location:otpProfessor.php");
}
$time_start=strtotime($time);
$time_end=strtotime($time_clicked);
if($time_end-$time_start<600 && $otp==$otp_sent){
header("Location:resetPasswordStu.php");
}
else if($time_end-$time_start>600){
echo "Session Expired";
echo "<form action='mailForgotOtp.php'>
<input type='submit' value='Resend OTP'>
</form>";
}
else{
echo "WRONG OTP!";
}
}
?>
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<input type="text" name="otp" placeholder="Enter 6 digit OTP">
<input type="submit" name="check">
</form>
</body>
</html>