-1
我的問題是,條件if(isset ... is not seeable。直到現在我沒有與PDO一起工作,所以如果有人看到我的問題的解決方案,請幫助我,如果可以的話,謝謝激活郵件和散列檢查
<?php
mysql_connect("localhost", "xxxx", "") or die(mysql_error()); // Connect to database server(localhost) with username and password.
mysql_select_db("database") or die(mysql_error()); // Select registration database.
這種情況如果不能看到
if (isset($_GET['e_mail']) && !empty($_GET['e_mail']) AND isset($_GET['hash']) && !empty($_GET['hash'])){
// Verify data
$email = mysql_escape_string($_GET['e_mail']); // Set email variable
$hash = mysql_escape_string($_GET['hash']); // Set hash variable
$search = mysql_query("SELECT e_mail, hash, active FROM users WHERE e_mail='".$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 e_mail='".$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>';
}
?>
***請[停止使用'mysql_ *'功能](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php)。*** [這些擴展名](http://php.net/manual/en/migration70.removed-exts-sapis.php)已在PHP 7中刪除。瞭解[prepared](http://en.wikipedia.org/wiki/Prepared_statement)語句[PDO](http://php.net/manual/en/pdo.prepared-statements.php)和[MySQLi](http://php.net/manual/en/mysqli.quickstart。 prepared-statements.php)並考慮使用PDO,[這真的很簡單](http://jayblanchard.net/demystifying_php_pdo.html)。 –
[小博](http://bobby-tables.com/)說***腳本是在對SQL注入攻擊的風險。(http://stackoverflow.com/questions/60174/how-can- I-防止-SQL注入式-PHP)***。即使[轉義字符串](http://stackoverflow.com/questions/5741187/sql-injection-that-gets-around-mysql-real-escape-string)是不安全的! –
你的代碼失敗了;檢查錯誤 –