-Karl- Posted April 17, 2010 Share Posted April 17, 2010 <?php if (isset($_GET['passkey'])) { // Passkey that got from link $passkey=mysql_real_escape_string($_GET['passkey']); // Retrieve data from table where row that match this passkey $query="SELECT * FROM temp WHERE confirmcode ='$passkey'"; $run = mysql_query($query); // If successfully queried if($run){ // Count how many row has this passkey $count=mysql_num_rows($run); // if found this passkey in our database, retrieve data from table if($count==1){ $rows=mysql_fetch_array($run); $username=$rows['username']; $password=$rows['password']; // Insert data that retrieves from temp in to users $sql2="INSERT INTO users (id, username, password)VALUES('','$username', '$password')"; $result2=mysql_query($sql2); } // if not found passkey, display message "Wrong Confirmation code" else { echo "Wrong Confirmation code"; } // if successfully moved data from table temp to table users displays message "Your account has been activated" and delete confirmation code from table if($result2){ echo "Your account has been activated"; // Delete information of this user from table that has this passkey $sql3="DELETE FROM temp WHERE confirmcode = '$passkey'"; $result3=mysql_query($sql3); } else { die('Error: ' . mysql_error()); } } } ?> Well there's my code, I just can't figure out what I'm missing. I've been over the code a few times and it looks fine. However, it doesn't return anything, even when using a correct code, and it does nothing when using a false one. Quote Link to comment https://forums.phpfreaks.com/topic/198815-confirmation-email-codes/ Share on other sites More sharing options...
Jax2 Posted April 17, 2010 Share Posted April 17, 2010 Try turning on error reporting and see if it generates any warnings, and also include a mysql_error echo after each query, that will tell you if it's a query problem. Usually due to a simple spelling error or something like that. Quote Link to comment https://forums.phpfreaks.com/topic/198815-confirmation-email-codes/#findComment-1043507 Share on other sites More sharing options...
-Karl- Posted April 17, 2010 Author Share Posted April 17, 2010 No luck so far Quote Link to comment https://forums.phpfreaks.com/topic/198815-confirmation-email-codes/#findComment-1043513 Share on other sites More sharing options...
DJTim666 Posted April 17, 2010 Share Posted April 17, 2010 Try this; <?php if (isset($_GET['passkey'])) { // Passkey that got from link $passkey=mysql_real_escape_string($_GET['passkey']); // Retrieve data from table where row that match this passkey $query="SELECT * FROM `temp` WHERE0 `confirmcode` ='{$passkey}'"; $run = mysql_query($query); // If successfully queried if($run){ // Count how many row has this passkey $count=mysql_num_rows($run); // if found this passkey in our database, retrieve data from table if($count==1){ $rows=mysql_fetch_array($run); $username=$rows['username']; $password=$rows['password']; // Insert data that retrieves from temp in to users $sql2="INSERT INTO `users` (`username`, `password`)VALUES('$username', '$password')"; $result2=mysql_query($sql2); } // if not found passkey, display message "Wrong Confirmation code" else { echo "Wrong Confirmation code"; } // if successfully moved data from table temp to table users displays message "Your account has been activated" and delete confirmation code from table if($result2){ echo "Your account has been activated"; // Delete information of this user from table that has this passkey $sql3="DELETE FROM `temp` WHERE `confirmcode` = '$passkey'"; $result3=mysql_query($sql3); } else { die('Error: ' . mysql_error()); } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/198815-confirmation-email-codes/#findComment-1043515 Share on other sites More sharing options...
-Karl- Posted April 17, 2010 Author Share Posted April 17, 2010 No change as ` in queries are not essential. Quote Link to comment https://forums.phpfreaks.com/topic/198815-confirmation-email-codes/#findComment-1043516 Share on other sites More sharing options...
DJTim666 Posted April 17, 2010 Share Posted April 17, 2010 Print your values and confirm you're getting the values you expect. Quote Link to comment https://forums.phpfreaks.com/topic/198815-confirmation-email-codes/#findComment-1043540 Share on other sites More sharing options...
-Karl- Posted April 17, 2010 Author Share Posted April 17, 2010 Nevermind, managed to debug it, it's now working perfectly Quote Link to comment https://forums.phpfreaks.com/topic/198815-confirmation-email-codes/#findComment-1043541 Share on other sites More sharing options...
oni-kun Posted April 17, 2010 Share Posted April 17, 2010 Why not see if the queries are actually running? Also you should learn basic code formatting... Also `temp` WHERE0 `confirmcode` The error in the first query is very obvious if you checked for it with the first step of debugging. EDIT: Sorry, browser lagged for 10 minutes to post Quote Link to comment https://forums.phpfreaks.com/topic/198815-confirmation-email-codes/#findComment-1043547 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.