我在下面的代码中有一个错误“注意:未定义的索引:srSend”。我有两个问题:
i)如果我抑制错误,为什么这段代码会起作用?未定义的索引是错误是否重要?ii) 无论如何,我该如何纠正这个错误?
<?php
//db connection
$mysqli = new mysqli("localhost", "root", "", "test");
if ($mysqli->connect_errno) {
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}
if($_POST['srSend'] && $_POST['srEmail']) {
//check if email already taken
if ($stmt = $mysqli->prepare("SELECT user_pin FROM users WHERE user_email = ?")) {
$stmt->bind_param("s", strtolower($_POST['srEmail']));
$stmt->execute();
$stmt->bind_result($user_pin);
$stmt->fetch();
$stmt->close();
}