所以連接已經建立,這裏是代碼。我試圖做的是從網址獲取兩個var並將它們保存爲var。我得到一個錯誤和PHP不工作,我知道URL中的信息是正確的,並與數據庫匹配。錯誤是「網址無效,或者您已經激活了您的帳戶。」這是什麼PHP返回,如果沒有一個匹配,所以即時通訊猜測斷開之間的url和var設置。 代碼:PHP-通過使用mysql進行url檢查var
if(isset($_GET['email']) && !empty($_GET['email']) AND isset($_GET['hash']) && !empty($_GET['hash'])){
// Verify data
$email = mysql_escape_string($_GET['email']); // Set email variable
$hash = mysql_escape_string($_GET['hash']); // Set hash variable
$search = mysql_query("SELECT email, hash, active FROM users WHERE email='".$email."' AND hash='".$hash."' AND active='0'") or die(mysql_error());
$match = mysql_num_rows($search);
if($match > 0){
// We have a match, activate the account
mysql_query("UPDATE users SET active='1' WHERE email='".$email."' AND hash='".$hash."' AND active='0'") or die(mysql_error());
echo '<div class="statusmsg">Your account has been activated, you can now login</div>';
}else{
// No match -> invalid url or account has already been activated.
echo '<div class="statusmsg">The url is either invalid or you already have activated your account.</div>';
}
}else{
// Invalid approach
echo '<div class="statusmsg">Invalid approach, please use the link that has been send to your email.</div>';
}
?>
網址:
http://www.aliahealthcare.com/verify.php?email= '.ME @ email.com。' & hash ='。67f7fb873eaf29526a11a9b7ac33bfac'。
什麼是不工作? – erisco
你得到的錯誤是? – ain
錯誤是「網址無效或您已經激活了您的帳戶。」這是什麼PHP返回,如果沒有一個匹配,所以即時通訊猜測斷開之間的url和var設置。 – Osman