0

卡了一会儿。我要做的是在验证码匹配时将 Enum 行的值更新为 yes。这里的代码..提前谢谢。

<?php
session_start();
include ('dbconnect.php');

$verify_code = $_POST['vercode'];

// To protect MySQL injection (more detail about MySQL injection)
$verify_code = mysqli_real_escape_string($conn, $verify_code);

//Select SQL query against table
$query = "SELECT Verify_Code FROM Member WHERE Verify_Code = '$verify_code';";
$result = mysqli_query($conn, $query) or die(mysqli_error());

while($row = mysqli_fetch_array($result)){

$update_query = "UPDATE Member SET Verified = 'yes' WHERE Verify_Code = '$verify_code';";
echo $update_query;
//header("Location:TwitchMain.php");
}
?>

echo 语句带回 UPDATE Member SET Verified = 'yes' WHERE Verify_Code = 'Q#icm'; 这是正确的代码。

4

1 回答 1

0

您根本不需要运行 SELECT 查询!只要运行一个更新查询,如果数据库中有这个验证码的成员,他就会被更新:

$verify_code = $_POST['vercode'];

$sql = "UPDATE Member SET Verified = 'yes' WHERE Verify_Code = ?";
if ($stmt = $conn->prepare($sql)) {
    $stmt->bind_param("s", $verify_code);
    $stmt->execute();
}
于 2013-11-09T07:46:22.173 回答