|
Server IP : 82.112.239.40 / Your IP : 216.73.216.81 Web Server : LiteSpeed System : Linux in-mum-web1676.main-hosting.eu 5.14.0-503.38.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Apr 18 08:52:10 EDT 2025 x86_64 User : u641149403 ( 641149403) PHP Version : 7.3.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : OFF | Python : OFF Directory (0777) : /home/u641149403/domains/uniformindia.co.in/public_html/ |
| [ Home ] | [ C0mmand ] | [ Upload File ] |
|---|
<?php
$success = "";
$error_message = "";
$conn = mysqli_connect("localhost","root","","groceryboy");
if(!empty($_POST["submit_email"])) {
$result = mysqli_query($conn,"SELECT * FROM users WHERE email='" . $_POST["email"] . "'");
$count = mysqli_num_rows($result);
if($count>0) {
// generate OTP
$otp = rand(100000,999999);
// Send OTP
require_once("mail_function.php");
$mail_status = sendOTP($_POST["email"],$otp);
if($mail_status == 1) {
$result = mysqli_query($conn,"INSERT INTO otp_expiry(otp,is_expired,create_at) VALUES ('" . $otp . "', 0, '" . date("Y-m-d H:i:s"). "')");
$current_id = mysqli_insert_id($conn);
if(!empty($current_id)) {
$success=1;
}
}
} else {
$error_message = "Email not exists!";
}
}
if(!empty($_POST["submit_otp"])) {
$result = mysqli_query($conn,"SELECT * FROM otp_expiry WHERE otp='" . $_POST["otp"] . "' AND is_expired!=1 AND NOW() <= DATE_ADD(create_at, INTERVAL 24 HOUR)");
$count = mysqli_num_rows($result);
if(!empty($count)) {
$result = mysqli_query($conn,"UPDATE otp_expiry SET is_expired = 1 WHERE otp = '" . $_POST["otp"] . "'");
$success = 2;
} else {
$success =1;
$error_message = "Invalid OTP!";
}
}
?>
<form name="frmUser" method="post" action="">
<div class="tblLogin">
<?php
if(!empty($success == 1)) {
?>
<div class="tableheader">Enter OTP</div>
<p style="color:#31ab00;">Check your email for the OTP</p>
<div class="tablerow">
<input type="text" name="otp" placeholder="One Time Password" class="login-input" required>
</div>
<div class="tableheader"><input type="submit" name="submit_otp" value="Submit" class="btnSubmit"></div>
<?php
} else if ($success == 2) {
?>
<p style="color:#31ab00;">Welcome, You have successfully loggedin!</p>
<?php
}
else {
?>
<div class="tableheader">Enter Your Login Email</div>
<div class="tablerow"><input type="text" name="email" placeholder="Email" class="login-input" required></div>
<div class="tableheader"><input type="submit" name="submit_email" value="Submit" class="btnSubmit"></div>
<?php
}
?>
</div>
</form>