freemancomputer Posted April 7, 2011 Share Posted April 7, 2011 I am working on user validation through email and I am having some problems with it. I can get it to work but it gives me probloms some times. This is the link that is sent to the users after they sign up mydomain/confirm.php?id=".$id."&userkey=".$userkey and this is what i have for the confirm page <?php //connection info $userquery = mysql_query("SELECT * FROM user"); $active=mysql_result($userquery, "active"); $userid=mysql_result($userquery, "id"); $userkey=mysql_result($userquery, "userkey"); if ($active == 1) { printf("This account has already been activated"); echo "<br />"; } elseif($userkey != $posteduserkey){ printf("We are sorry but the data offered does not match data listed, plese contact system admin."); } else{ $query="UPDATE user SET active='1' WHERE id='$id'"; mysql_query($query) or die (mysql_error()); echo "You have activated your account"; ?> <div align="center"><br /><a href="login.php" class="nav">Back to the log in page</a></div> <?php } ?> This is the fun part. I checked that the id and userkey are correct in the link, and they are. I then replaced the & in the link with & it works in gmail but not yahoo email address. I'm not sure where else to look. Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/232932-user-validation-via-email/ Share on other sites More sharing options...
Lyleyboy Posted April 8, 2011 Share Posted April 8, 2011 I think what you need to do is to formulate your variables so:- $id = $_GET['id']; $userkey = $_GET['userkey']; I believe the issue is that the php does not always know for certain what the variable contents are. Quote Link to comment https://forums.phpfreaks.com/topic/232932-user-validation-via-email/#findComment-1198735 Share on other sites More sharing options...
freemancomputer Posted April 9, 2011 Author Share Posted April 9, 2011 Sorry that is in there, just cut it out when I cut out the log in info. $id = mysql_real_escape_string(urldecode($_GET["id"])); $posteduserkey = mysql_real_escape_string(urldecode($_GET["userkey"])); Quote Link to comment https://forums.phpfreaks.com/topic/232932-user-validation-via-email/#findComment-1199096 Share on other sites More sharing options...
dcro2 Posted April 9, 2011 Share Posted April 9, 2011 Hoold on there. This is how you use mysql_result: string mysql_result ( resource $result , int $row [, mixed $field = 0 ] ) Field name is the third argument, not the second. You're also getting the first row in the user table, not the row for the user you're trying to check... come on now. <?php //connection info $userquery = mysql_query("SELECT * FROM user WHERE id='$id'") or die(mysql_error()); if(mysql_num_rows($userquery) == 0) { printf("Could not find the information for this user."); exit; } $active=mysql_result($userquery, 0, "active"); $userid=mysql_result($userquery, 0, "id"); $userkey=mysql_result($userquery, 0, "userkey"); if ($active == 1) { printf("This account has already been activated"); echo "<br />"; } elseif($userkey != $posteduserkey){ printf("We are sorry but the data offered does not match data listed, plese contact system admin."); } else{ $query="UPDATE user SET active='1' WHERE id='$id'"; mysql_query($query) or die (mysql_error()); echo "You have activated your account"; ?> <div align="center"><br /><a href="login.php" class="nav">Back to the log in page</a></div> <?php } ?> Quote Link to comment https://forums.phpfreaks.com/topic/232932-user-validation-via-email/#findComment-1199103 Share on other sites More sharing options...
freemancomputer Posted April 9, 2011 Author Share Posted April 9, 2011 wow cant believe i missed that one thanks. Quote Link to comment https://forums.phpfreaks.com/topic/232932-user-validation-via-email/#findComment-1199106 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.