forked from SAAR-IITP/SAAR-IITP
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathotpvalidationp.php
48 lines (48 loc) · 1.67 KB
/
otpvalidationp.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
<?php
session_start();
if($_SERVER["REQUEST_METHOD"] == "POST") {
$url = "http://api.saar.iitp.ac.in/verifyOTP.php";
$ch = curl_init($url);
$data = array(
'rollno' => $_POST['rollno'],
'verification_code' => $_POST['otp'],
'access_token' => $_SESSION['access_token']
);
if(isset($_POST['forget_pass'])){
$data += array('forgot_password' => $_POST['forget_pass']);
}
$payload = http_build_query($data);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
$response = json_decode($result,true);
if($response['status'] == 201){
$_SESSION['error'] = $response['messages'][0];
unset($_SESSION['fname']);
unset($_SESSION['lname']);
unset($_SESSION['cid']);
unset($_SESSION['contact']);
unset($_SESSION['fb']);
unset($_SESSION['graduation']);
unset($_SESSION['degree']);
unset($_SESSION['dept']);
unset($_SESSION['linkden']);
unset($_SESSION['dob']);
unset($_SESSION['cid']);
unset($_SESSION['email']);
unset($_SESSION['loggedin']);
header("location: signin.php");
}else if($response['status']==208){
//forget password redirect to set password page
$_SESSION['cid'] = $response['messages']['rollno'];
$_SESSION['msg'] = $response['messages']['msg'];
$_SESSION['forget_pass'] = true;
header("location: changePassword.php");
}else{
$_SESSION['error'] = $response['messages'][0];
header("location: enterotp.php");
}
}
?>