-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphone.php
More file actions
48 lines (47 loc) · 1.55 KB
/
Copy pathphone.php
File metadata and controls
48 lines (47 loc) · 1.55 KB
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
<!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="phone.php" method="post">
<input type="text" name="mobileNumber" id ="mobileNUmber" placeholder="enter number">
<input type="submit" name="generate" value="generate OTP">
<input type="text" name="otp" id="otp" placeholder="enter otp" >
<input type="submit" value="verify" name="verify">
</form>
</body>
</html>
<?php
if(isset($_POST['generate'])){
$apiKey = urlencode('woVNK+hUOrA-5HDvXFBoaSciBZuF8GavMC57ta5lPp');
$sender = urlencode('TXTLCL');
@$numbers = $_POST['mobileNumber'];
$otp =mt_rand(100000,999999);
setcookie("otp");
$message = "hey your otp is ".$otp;
// $numbers = implode(',', $numbers);
// Prepare data for POST request
$data = array('apikey' => $apiKey, 'numbers' => $numbers, "sender" => $sender, "message" => $message);
// Send the POST request with cURL
$ch = curl_init('https://api.textlocal.in/send/');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
echo "otp sent";
curl_close($ch);
if(isset($_POST['verify'])){
$verotp=$_POST['otp'];
if($verotp==$_COOKIES('otp')){
echo"otp verified";
}
else{
echo"otp is wrong";
}
}
}
?>