激活邮件和哈希检查 [英] Activation mail and hash check

查看:203
本文介绍了激活邮件和哈希检查的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是,条件if(isset ...不可见,直到现在我没有使用PDO,所以如果有人看到我的问题的解决方案,请帮助我,如果可以的话谢谢。

 <?php 

mysql_connect(localhost,xxxx,)或死(mysql_error()) ; //使用用户名和密码连接到数据库服务器(localhost)
mysql_select_db(database)or die(mysql_error()); //选择注册数据库

如果条件无法看到

  if(isset($ _ GET ['e_mail'])&&empty($ _ GET ['e_mail'])AND isset($ _ GET ['hash'])&空($ _ GET ['hash'])){
//验证数据
$ email = mysql_escape_string($ _ GET ['e_mail']); //设置电子邮件变量
$ hash = mysql_escape_string($ _ GET ['hash']); //设置哈希变量

$ search = mysql_query(SELECT e_mail,hash,active FROM用户WHERE e_mail ='$ email。'AND hash ='。$ hash。'AND active ='0')或死(mysql_error());
$ match = mysql_num_rows($ search);

我想这样做:

  if($ match> 0){
//我们有一个匹配,激活帐户
mysql_query(UPDATE users SET active ='1'WHERE e_mail ='$ email。'AND hash ='。$ hash。'AND active ='0')或死(mysql_error());
echo'< div class =statusmsg>您的帐户已激活,您现在可以登录< / div>';
} else {
//无匹配 - >无效的网址或帐户已被激活。
echo'< div class =statusmsg>该网址无效或您已经激活了您的帐户。< / div>';
}


}

如果条件是这样的:

  else {


//无效方法
echo'< div class =statusmsg>无效的方法,请使用已发送到您的电子邮件的链接< / div>';

}
?>


解决方案

我发现错误在哪里
这听起来令人难以置信,但是错误在设置了底线(_)的数据库中,当我输入电子邮件而不是 e_mail 在数据库中,并纠正一切,它的工作完美。



我上传了答案,所以可以帮助其他同样的情况。



我非常感谢Jay Blanchard在PDO工作的建议,我会发送他的adevice,因为它是令人信服的,谢谢Fred的答案。

现在,如果有人可以帮助我在PDO中做(写,制作)这个代码,并解释我PDO的工作原理,以便更好地了解它。谢谢!


My question is,condition if(isset... is not seenable. Until now i didnt work with PDO so if someone sees the solution for my problem, please help me if you can, thanks.

    <?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.

This if condition can't be seen

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);

I want to do this condition:

            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>';
            }


        }

if condition does this:

else{


                // Invalid approach
                echo '<div class="statusmsg">Invalid approach, please use the link that has been send to your email.</div>';

            }
            ?>

解决方案

I found where the mistake is, it sounds incredibly but the mistake is in database where the bottom line ( _ ) is set, and when i input email instead of e_mail in database and correct everything, it works perfectly.

I uploaded the answer so it can help others with the same situation.

I really appreciate Jay Blanchard´s advice to work in PDO and i will send his adevice because it is convincing, and thank you Fred for your answer.

Now if someone can help me to do(write,make) this code in PDO and to explain me how PDO works in order to understand it better. Thanks!

这篇关于激活邮件和哈希检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆