Create send_otp.php

This commit is contained in:
PascalMwawasi 2025-09-29 15:05:09 +03:00 committed by GitHub
parent ec08e9497d
commit 9f6271ef12
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 44 additions and 0 deletions

44
send_otp.php Normal file
View File

@ -0,0 +1,44 @@
<?php
session_start();
// DB connection
$host = "localhost";
$user = "root"; // change if different
$pass = ""; // change if different
$db = "cada_db"; // change to your DB name
$conn = new mysqli($host, $user, $pass, $db);
if ($conn->connect_error) {
die("Database connection failed: " . $conn->connect_error);
}
// Collect form data
$surname = $_POST['surname'];
$other_names = $_POST['other_names'];
$national_id_number = $_POST['national_id_number'];
$dob = $_POST['dob'];
$sex = $_POST['sex'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$county = $_POST['county'];
$constituency = $_POST['constituency'];
$ward = $_POST['ward'];
$consent = isset($_POST['consent']) ? 1 : 0;
// Save to DB
$sql = "INSERT INTO members (surname, other_names, national_id_number, dob, sex, email, phone, county, constituency, ward, consent)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
$stmt = $conn->prepare($sql);
$stmt->bind_param("ssssssssssi", $surname, $other_names, $national_id_number, $dob, $sex, $email, $phone, $county, $constituency, $ward, $consent);
if ($stmt->execute()) {
echo "success";
} else {
echo "error: " . $stmt->error;
}
$stmt->close();
$conn->close();
?>