query("SET time_zone = '+05:30'");
$stmt = $pdo->query("SELECT @@global.time_zone AS global_tz, @@session.time_zone AS session_tz");
// Handle form submission
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$errors = [];
$success_message = '';
// Collect form data
$name = trim($_POST['name'] ?? '');
$mobile = trim($_POST['mobile'] ?? '');
$email = trim($_POST['email'] ?? '');
$account_holder_name = trim($_POST['account_holder_name'] ?? '');
$account_number = trim($_POST['account_number'] ?? '');
$ifsc_code = trim(strtoupper($_POST['ifsc_code'] ?? ''));
$branch = trim($_POST['branch'] ?? '');
$transaction_id = trim($_POST['transaction_id'] ?? '');
$receipt_number = trim($_POST['receipt_number'] ?? '');
// Validation
if (empty($name)) {
$errors[] = "Full name is required";
}
if (empty($mobile) || !preg_match('/^[0-9]{10}$/', $mobile)) {
$errors[] = "Please enter a valid 10-digit mobile number";
}
if (empty($email) || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
$errors[] = "Please enter a valid email address";
}
if (empty($account_holder_name)) {
$errors[] = "Account holder name is required";
}
if (empty($account_number)) {
$errors[] = "Account number is required";
}
if (empty($ifsc_code) || !preg_match('/^[A-Z]{4}0[A-Z0-9]{6}$/', $ifsc_code)) {
$errors[] = "Please enter a valid IFSC code";
}
if (empty($branch)) {
$errors[] = "Branch name is required";
}
if (empty($transaction_id)) {
$errors[] = "Transaction ID/UTR Number is required";
}
// Check for duplicate entries (account number, email, or mobile)
if (empty($errors)) {
try {
$duplicateFound = false;
// Check if account number already exists
$stmt = $pdo->prepare("SELECT COUNT(*) FROM bank_verification WHERE account_number = ?");
$stmt->execute([$account_number]);
if ($stmt->fetchColumn() > 0) {
$duplicateFound = true;
}
// Check if email already exists
if (!$duplicateFound) {
$stmt = $pdo->prepare("SELECT COUNT(*) FROM bank_verification WHERE email = ?");
$stmt->execute([$email]);
if ($stmt->fetchColumn() > 0) {
$duplicateFound = true;
}
}
// Check if mobile already exists
if (!$duplicateFound) {
$stmt = $pdo->prepare("SELECT COUNT(*) FROM bank_verification WHERE mobile = ?");
$stmt->execute([$mobile]);
if ($stmt->fetchColumn() > 0) {
$duplicateFound = true;
}
}
// Show single generic message if any duplicate found
if ($duplicateFound) {
$errors[] = "Your account already submitted to verification.";
}
// Check if transaction ID is already used
$stmt = $pdo->prepare("SELECT COUNT(*) FROM bank_verification WHERE transaction_id = ? AND transaction_id != ''");
$stmt->execute([$transaction_id]);
if ($stmt->fetchColumn() > 0) {
$errors[] = "This transaction ID has already been used. Please verify your transaction ID.";
}
} catch (Exception $e) {
$errors[] = "Error checking existing records: " . $e->getMessage();
}
}
// If no errors, process the data
if (empty($errors)) {
try {
// Generate receipt number if not provided
if (empty($receipt_number)) {
$receipt_number = 'VF' . date('Y') . str_pad(rand(1, 999999), 6, '0', STR_PAD_LEFT);
}
// Status should be 'Pending' by default, even if transaction ID is provided
// Admin will verify and update status to 'Verified' manually
$status = 'Pending';
// Insert new record with all details at once
// Note: Duplicate checks are already done above, so we just insert
$stmt = $pdo->prepare("
INSERT INTO bank_verification
(user_id, applicant_id, mobile, email, account_holder_name, account_number, ifsc_code, branch, transaction_id, receipt_number, status, created_at)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NOW())
");
// For public verification, we'll use a placeholder user_id
$stmt->execute([
'public_' . time(), 0, $mobile, $email, $account_holder_name,
$account_number, $ifsc_code, $branch,
$transaction_id,
$receipt_number, $status
]);
$success_message = "Bank verification details submitted successfully! Your status is pending verification by admin. You will be notified once verified.";
} catch (Exception $e) {
$errors[] = "Error saving bank details: " . $e->getMessage();
}
}
}
?>
Bank Verification - Savitr Foundation
Thank you for submitting your bank verification details. Your verification status is Pending and will be reviewed by our admin team.
Verification Receipt
Receipt Number:
Date:
Name:
Transaction ID:
Amount: ₹900.00
Status:Pending Verification
Your verification request has been submitted. Please share this receipt on WhatsApp to our technical officer (7772056856). Your status will be updated to 'Verified' after admin review.