<?php
if (isset($_GET['key']) && isset($_GET['username'])) {
$activationQuery = "SELECT activationKey FROM users WHERE username = :username";
$activationQueryParams = array(':username' => $_GET['username']);
try {
$stmt = $db->prepare($activationQuery);
$result = $stmt->execute($activationQueryParams);
} catch(PDOException $ex) {
die("Failed to run query: " . $ex->getMessage());
}
$activationRowCount = $stmt->rowCount();
if ($activationRowCount) {
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)){
$key = $_GET['key'];
$databaseKey = $row['activationKey'];
if ($key == $databaseKey) {
$updateActivated = "UPDATE users SET activated = 1 WHERE username = :username";
$updateActivatedParams = array(':username' => $_GET['username']);
try {
$stmt = $db->prepare($updateActivated);
$result = $stmt->execute($updateActivatedParams);
} catch(PDOException $ex) {
die("Failed to run query: " . $ex->getMessage());
}
$updateKey = "UPDATE users SET activationKey = '' WHERE username = :username";
$updateKeyParams = array(':username' => $_GET['username']);
try {
$stmt = $db->prepare($updateKey);
$result = $stmt->execute($updateKeyParams);
} catch(PDOException $ex) {
die("Failed to run query: " . $ex->getMessage());
}
echo "Your account has been activated!";
} else {
echo "Sorry, it looks like that activation key doesn't exist!";
}
}
}
}
?>
现在,这段代码可以正常运行。我遇到的问题是当它通过所有检查并让我回复时:
您的帐户已被激活!
当它吐出该消息时,它会终止其下面的所有HTML运行。但是当条件不满足并且它吐出错误回声时,HTML就会很好地呈现而没有任何问题。
我已经多次看了这个,看不到我需要改变的东西,但是,这就是我在这里问的原因。希望它是我错过的一些简单。