File manager - Edit - /home/autoph/public_html/api/aha/send_passwordresetOTP.php
Back
<?php // MySQL connection parameters $servername = "localhost"; $username = "autoph_admindb"; $password = "~cxk)gU^ziaB"; $database = "autoph_ahg_crm"; // Create connection $conn = new mysqli($servername, $username, $password, $database); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $mykey = $_GET['keyID']; ; if($mykey =="OTP-6e59e008b5348b452bsendOTOP615a3033729daae383-email"){ $emailAdd = $_GET['emailAddress']; $userID = $_GET['userID']; // Check if e-mail exist in old_aha_database $sql = "SELECT * FROM `aha_old_customer_data` WHERE `deleted` = 0 AND `email_a`='$emailAdd' || `deleted` = 0 AND `email_b`='$emailAdd'"; $result = $conn->query($sql); if ($result->num_rows > 0) { //CREATE RANDOM CODE function generateAlphanumericOTP($length = 8) { $characters = '23456789abcdefghjkmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ'; $charactersLength = strlen($characters); $otp = ''; for ($i = 0; $i < $length; $i++) { $otp .= $characters[random_int(0, $charactersLength - 1)]; } return $otp; } $myOTP = generateAlphanumericOTP(8); // Example output: 3G4kLm7P //SEND CODE TO EMAIL ADDRESS $to = $emailAdd; $subject = 'OTP Code'; $message = "You OTP code is \r\n\n".$myOTP; // Additional headers $headers .= 'From: noreply@autohub.ph' . "\r\n"; $headers .= 'Reply-To: noreply@autohub.ph' . "\r\n"; $headers .= 'X-Mailer: PHP/' . phpversion(); // Send the email if (mail($to, $subject, $message, $headers)) { $returnMessage = 'OTP code has been sent to your registered email address.'; $myClass ="successClass"; $viewValidationForm = "Visible"; } else { $returnMessage = 'Failed to send OTP Code your email address. Please contact Autohub Support for assistance.'; $myClass ="errorClass"; $viewValidationForm = ""; } //INSERT OTP CODE TO TABLE FOR LATER VALIDATION $sql = "UPDATE `aha_old_customer_data` SET `email_otp`='$myOTP' WHERE `deleted` = 0 AND `email_a`='$emailAdd' || `deleted` = 0 AND `email_b`='$emailAdd'"; if ($conn->query($sql) === TRUE) { $returnMessage = 'OTP code has been sent to your registered email address.'; $myClass = "successClass"; $viewValidationForm = "Visible"; }else{ $returnMessage = 'Failed to send OTP Code your email address. Please contact Autohub Support for assistance.'; $myClass = "errorClass"; $viewValidationForm = ""; } }else{ $returnMessage = 'Your e-mail address cannot be found.'; $myClass = "errorClass"; $viewValidationForm = ""; } echo json_encode(["status" => "$returnMessage","class" => "$myClass","isVisible" =>"$viewValidationForm"]); } if($mykey =="OTP-6e59e008b5348b452bsendOTOP615a3033729daae383-mobile"){ $emailAdd = $_GET['email_address']; $userID = $_GET['userID']; function generateSecureNumericOTP($length = 6) { $otp = ""; for ($i = 0; $i < $length; $i++) { $otp .= random_int(0, 9); } return $otp; } $myOTPCode = generateSecureNumericOTP(); // Example output: 837592 } $conn->close(); ?>
| ver. 1.4 |
.
| PHP 7.3.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings