激活邮件和哈希检查

编程入门 行业动态 更新时间:2024-10-15 18:22:18
本文介绍了激活邮件和哈希检查的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我的问题是,条件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!

更多推荐

激活邮件和哈希检查

本文发布于:2023-11-25 10:44:37,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1629444.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:邮件

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!