当用户输入系统中未找到的电子邮件地址时,我试图显示错误。到目前为止,即使电子邮件与其他正确的回显结果一起在系统中,它也会在结果页面上回显。
<?php
$db = new mysqli(" ", " ", " ", "volsched");
if ($db->connect_errno) {
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}
$stmt = $db->prepare('UPDATE volConfirm SET confirmed = "YES" WHERE email = ?');
if (!$mysqli->error) {
printf("Errormessage: Email not in system %s\n", $mysqli->error);
}
$stmt->bind_param('s', $_POST['email']);
$stmt->execute();
$stmt = $db->prepare('SELECT agreename, position, shift_times, confirmed from volConfirm WHERE email = ?');
$stmt->bind_param('s', $_POST['email']);
$stmt->execute();
$stmt->bind_result($agreeName, $position, $shift_times, $confirmed);
while ($stmt->fetch()) {
// construct your output here using $row to access database record
echo "<h2>" . $agreeName . "</h2>";
echo "<p> You have been assigned as a volunteer for:" . $position . "</p>";
echo "<p>Your shift times are scheduled for:" . $shift_times . "</p>";
echo "<p>Your shift has been confirmed:" . $confirmed . "</p>";
}
?>