如何向此 pdo 脚本添加电子邮件验证。用户在“文本字段”中输入他们的电子邮件地址。只是如果输入的电子邮件地址不在数据库中,我希望它重定向到 fail.html
<?php
$host=""; // Host name
$username=""; // Mysql username
$password=""; // Mysql password
$db_name=""; // Database name
$tbl_name="orders"; // Table name
$email = $_POST['textfield'];
$db = new PDO('mysql:host='.$host.
';dbname='.$db_name.
';charset=UTF-8',
$username, $password);
$stmt = $db->prepare('SELECT * FROM `orders` WHERE `email`=:email LIMIT 1');
$stmt->bindValue(':email', $email, PDO::PARAM_STR);
$stmt->execute();
$result = $stmt->fetch(PDO::FETCH_ASSOC);
echo "The is: ".$result['name'].", and mail is: ".$result['email']." . Status: ".$result['status'];
?>