OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
cream
/
hps
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
06/17/2025 10:17:24 AM
rwxrwxr-x
📄
dashboard.php
3.64 KB
05/19/2025 10:07:13 AM
rw-r--r--
📄
hpsdb.php
351 bytes
05/19/2025 10:07:13 AM
rw-r--r--
📄
index.php
3.82 KB
05/19/2025 10:07:13 AM
rw-r--r--
📄
send_otp.php
795 bytes
05/19/2025 10:07:13 AM
rw-r--r--
📄
submit_form.php
7.17 KB
05/19/2025 10:07:13 AM
rw-r--r--
📄
verify_otp.php
4.86 KB
05/19/2025 10:07:13 AM
rw-r--r--
Editing: verify_otp.php
Close
<?php // Include database connection file include_once('hpsdb.php'); // Assuming you have a file to connect to your DB // Get the userId and OTP from the GET request $userId = isset($_GET['userId']) ? $_GET['userId'] : ''; // userId passed in the URL $otp = isset($_GET['otp']) ? $_GET['otp'] : ''; // OTP passed in the URL // Validate input if (empty($userId) || empty($otp)) { echo json_encode([ "status" => "error", "message" => "User ID and OTP are required." ]); exit; } // Function to verify OTP function verifyOtp($userId, $otp, $hpsdb) { // Current timestamp $currentTime = date("Y-m-d H:i:s"); $storedOtp = ''; $expiry = ''; // Query to fetch the OTP and expiry for the given userId $sql = "SELECT otp, expiry FROM otp WHERE userId = ? ORDER BY expiry DESC LIMIT 1"; $stmt = $hpsdb->prepare($sql); $stmt->bind_param('i', $userId); // 'i' means integer for $userId $stmt->execute(); $stmt->store_result(); $stmt->bind_result($storedOtp, $expiry); // Check if a record was found for the user if ($stmt->num_rows > 0) { // Fetch the data $stmt->fetch(); $storedOtp = (int)$storedOtp; $expiry = (int)$expiry; // Check if the OTP has expired if ($currentTime > $expiry) { return [ "status" => "error", "message" => "OTP has expired. Please request a new one." ]; } // Compare the stored OTP with the user-provided OTP if ($otp === $storedOtp) { // Update the 'students' table to mark the user as verified $sqlUpdate = "UPDATE students SET isVerified = 1 WHERE id = ?"; $stmtUpdate = $hpsdb->prepare($sqlUpdate); $stmtUpdate->bind_param('i', $userId); // 'i' means integer for $userId $stmtUpdate->execute(); if ($stmtUpdate->affected_rows > 0) { // If the update was successful return [ "status" => "success", "message" => "OTP verified successfully and user is now verified." ]; } else { // If no rows were affected by the update (possibly user was already verified) return [ "status" => "error", "message" => "Failed to update verification status. Please try again." ]; } } else { return [ "status" => "error", "message" => "Incorrect OTP. Please try again." ]; } } else { return [ "status" => "error", "message" => "No OTP found for the provided user ID." ]; } } // Call the verifyOtp function $response = verifyOtp($userId, (int)$otp, $hpsdb); // Return the result as a JSON response // echo json_encode($result); // echo $result['message']; ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>OTP Verification</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> <div class="container"> <h2>OTP Verification</h2> <div class="message <?= $response['status'] === 'success' ? 'success' : 'error'; ?>"> <strong><?= ucfirst($response['status']); ?>:</strong> <?= $response['message']; ?> </div> <a href="dashboard.php" class="btn">Go to Homepage</a> <!-- You can link to your homepage or other page --> </div> </body> </html>