OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
3-31-025chanakya
/
hps
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
03/31/2025 06:36:42 AM
rwxr-xr-x
📄
dashboard.php
3.64 KB
03/26/2025 03:48:05 AM
rw-r--r--
📄
hpsdb.php
351 bytes
03/26/2025 03:48:05 AM
rw-r--r--
📄
index.php
3.82 KB
03/26/2025 03:48:05 AM
rw-r--r--
📄
send_otp.php
795 bytes
03/26/2025 03:48:05 AM
rw-r--r--
📄
submit_form.php
7.17 KB
03/26/2025 03:48:05 AM
rw-r--r--
📄
verify_otp.php
4.86 KB
03/26/2025 03:48:05 AM
rw-r--r--
Editing: submit_form.php
Close
<?php require_once 'hpsdb.php'; use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; require dirname(__FILE__) . '/../inc/PHPMailer/Exception.php'; require dirname(__FILE__) . '/../inc/PHPMailer/PHPMailer.php'; require dirname(__FILE__) . '/../inc/PHPMailer/SMTP.php'; function sendEmail($toName, $toEmail, $toEmailCC, $emailSubject, $emailBody) { $mail = new PHPMailer(true); try { $mail->isSMTP(); // $mail->setFrom('donotreply@knoblycream.com', 'Knobly Cream'); // $mail->Username = 'AKIARWSGL3TOGXCYQJVY'; // $mail->Password = 'BIj9DvNM3uX+cckSX4So50fqln6DEhie6dMJpe3AjzqK'; // $mail->Host = 'email-smtp.ap-south-1.amazonaws.com'; // $mail->setFrom('cream@knobly.com', 'Knobly Cream'); // $mail->Username = '16486ca9-f4d0-4d09-9739-b48a16a8586e'; // $mail->Password = '16486ca9-f4d0-4d09-9739-b48a16a8586e'; // $mail->Host = 'smtp.postmarkapp.com'; // $mail->addCustomHeader('X-PM-Message-Stream', 'outbound'); $mail->setFrom('donotreply@knobly.com', 'Knobly Cream'); $mail->Host = 'smtp.gmail.com'; $mail->Username = 'donotreply@knobly.com'; $mail->Password = 'ipmhstdrbkwfhcna'; $mail->Port = 587; $mail->SMTPAuth = true; $mail->SMTPSecure = 'tls'; // Add recipient addresses if ($toEmail != '') { $arrEmail = explode(',', $toEmail); foreach ($arrEmail as $value) { $mail->addAddress(trim($value)); } } // Add CC addresses if ($toEmailCC != '') { $arrCC = explode(',', $toEmailCC); foreach ($arrCC as $value) { $mail->addCC(trim($value)); } } // Add BCC address $mail->addBCC('chiranjeev@gmail.com'); // Set email format to HTML $mail->isHTML(true); $mail->Subject = $emailSubject; $mail->Body = $emailBody; // Send the email $mail->send(); // Return success status if email sent return [ "status" => "success", "message" => "Email has been sent successfully." ]; } catch (Exception $e) { // Return error status if email fails to send return [ "status" => "error", "message" => "Message could not be sent. Mailer Error: " . $mail->ErrorInfo ]; } } // Function to generate and send OTP, and return result as an array function sendOtp($userId, $name, $email, $hpsdb) { // Generate a random OTP (6 digits) $otp = rand(100000, 999999); // Set OTP expiration time (5 minutes from now) $otpExpiry = date("Y-m-d H:i:s", strtotime("+5 minutes")); echo $otp . "<br>" . $otpExpiry . "<br>"; // Insert OTP into database $sql = "INSERT INTO otp (userId, otp, expiry) VALUES ($userId, $otp, '$otpExpiry') ON DUPLICATE KEY UPDATE otp = $otp, expiry = '$otpExpiry'"; if ($hpsdb->query($sql) === TRUE) { // Prepare email details $emailSubject = "Your OTP Code for Registration"; $emailBody = " Hello $name,<br><br> Your OTP code is: <strong>$otp</strong><br><br> Please use this OTP to complete your registration by clicking the link below:<br><br> <a href='https://knoblycream.com/hps/verify_otp.php?userId=$userId&otp=$otp'>Click here to verify your OTP</a><br><br> If you didn't request this OTP, please ignore this email.<br><br> Best regards,<br> HPS "; // Send OTP email using your sendEmail function $emailSent = sendEmail($name, $email, "", $emailSubject, $emailBody); // Return the result as an array if ($emailSent['status'] == "success") { return [ "status" => "success", "message" => "OTP has been sent to your email." ]; } else { return [ "status" => "error", "message" => "Error: Could not send OTP email." . $emailSent['message'] ]; } } else { return [ "status" => "error", "message" => "Error: Could not save OTP to database." ]; } } $name = $_POST['name']; $dob = $_POST['dob']; $fatherName = $_POST['fatherName']; $passedOutYear = $_POST['passedOutYear']; $houseColor = $_POST['houseColor']; $phoneNumber = $_POST['phoneNumber']; $email = $_POST['mail']; ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Verify User | HPS</title> <style> body { font-family: Arial, sans-serif; background-color: #f4f7f6; margin: 0; padding: 0; display: flex; justify-content: center; align-items: center; height: 100vh; } .container { background-color: white; padding: 40px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); border-radius: 8px; width: 400px; text-align: center; } .message { padding: 20px; border-radius: 4px; font-size: 16px; } .success { background-color: #e0f7e0; color: #2c6f2b; } .error { background-color: #f8d7da; color: #721c24; } .btn { background-color: #007bff; color: white; padding: 10px 20px; border: none; border-radius: 4px; cursor: pointer; text-decoration: none; display: inline-block; margin-top: 20px; } .btn:hover { background-color: #0056b3; } </style> </head> <body> <? // Prepare SQL query to insert data (also including OTP) $sql = "INSERT INTO students (name, dob, father_name, yop, house_color, phone_number, email) VALUES ('$name', '$dob', '$fatherName', '$passedOutYear', '$houseColor', '$phoneNumber', '$email')"; // Execute the query and check for success if ($hpsdb->query($sql) === TRUE) { $userId = $hpsdb->insert_id; // echo "New record created successfully!<br>"; $otpResponse = sendOtp($userId, $name, $email, $hpsdb); } else { $otpResponse = [ 'status' => 'error', 'message' => $hpsdb->error ]; } ?> <div class="container"> <h2>Submit Details</h2> <div class="message <?= $otpResponse['status'] === 'success' ? 'success' : 'error'; ?>"> <strong><?= ucfirst($otpResponse['status']); ?>:</strong> <?= $otpResponse['message']; ?> </div> <a href="dashboard.php" class="btn">Go to Homepage</a> <!-- You can link to your homepage or other page --> </div> <? // Close the connection $hpsdb->close(); ?> </body> </html>