激活邮件和哈希检查
Activation mail and hash check
我的问题是,条件 if(isset... 不可见。直到现在我还没有使用 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条件看不到
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>';
}
?>
找到错误的地方了,
这听起来令人难以置信,但错误出在设置了 底线 ( _ ) 的数据库中,当我输入 email 而不是 e_mail 在数据库中并更正所有内容,它完美地工作。
我上传了答案,希望对遇到相同情况的其他人有所帮助。
我非常感谢 Jay Blanchard 建议在 PDO 工作,我会发送他的设备,因为它很有说服力,感谢 Fred 的回答。
现在,如果有人可以帮助我在 PDO 中完成(编写、制作)这段代码,并向我解释 PDO 的工作原理,以便更好地理解它。谢谢!
我的问题是,条件 if(isset... 不可见。直到现在我还没有使用 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条件看不到
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>';
}
?>
找到错误的地方了, 这听起来令人难以置信,但错误出在设置了 底线 ( _ ) 的数据库中,当我输入 email 而不是 e_mail 在数据库中并更正所有内容,它完美地工作。
我上传了答案,希望对遇到相同情况的其他人有所帮助。
我非常感谢 Jay Blanchard 建议在 PDO 工作,我会发送他的设备,因为它很有说服力,感谢 Fred 的回答。
现在,如果有人可以帮助我在 PDO 中完成(编写、制作)这段代码,并向我解释 PDO 的工作原理,以便更好地理解它。谢谢!