Enter Your Email
connect_error) {
die("Connection failed: " . $conn->connect_error);
}
if (isset($_POST['submit'])) {
$email = $_POST['email'];
// Prepare and execute SQL statement to check if email exists
$check_sql = "SELECT * FROM visitor WHERE Email = ?";
$check_stmt = $conn->prepare($check_sql);
$check_stmt->bind_param("s", $email);
$check_stmt->execute();
$check_result = $check_stmt->get_result();
if ($check_result->num_rows > 0) {
echo "Email address already exists.
";
} else {
// Prepare and execute SQL statement to insert email
$sql = "INSERT INTO visitor (Email) VALUES (?)";
$stmt = $conn->prepare($sql);
$stmt->bind_param("s", $email);
if ($stmt->execute()) {
echo "Email submitted successfully!
";
} else {
echo "Error: " . $stmt->error;
}
$stmt->close();
}
$check_stmt->close();
}
$conn->close();
?>