elijahkan14 Posted February 18, 2014 Share Posted February 18, 2014 I'm almost there, I have two tables, one stores unverified users, the other stores all users and has a column labeled "Verified" which is either a 1 or 0. The code is able to check the hash sent in the email link and is able to get as far as deleting the user from the "unverified" table. The code does not change "Verified" from 0 to 1 on the "users" table. $SQL_REQUEST = "SELECT * FROM `unverified` WHERE `Hash`='$Hash'"; $SQL_RESULT = mysqli_query($DB_CON, $SQL_REQUEST); $SQL_VALID = mysqli_num_rows($SQL_RESULT); if($SQL_VALID > 0){ mysqli_query($DB_CON,"UPDATE users SET Verified=1 WHERE Username='$USERNAME'"); mysqli_query($DB_CON,"DELETE FROM `unverified` WHERE `Hash`='$Hash'"); echo '<p>Your account has been activated, you can now login <a href="https://www.site.org/login/">here</a></p>'; mysqli_close($DB_CON); exit(); } else{ die("The hash and/or username you provided was incorrect. If you believe this is an error, please contact customer support."); } Any help would be greatly appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/286288-help-with-email-verification/ Share on other sites More sharing options...
WebStyles Posted February 21, 2014 Share Posted February 21, 2014 so basically you're saying this line does not work as expected: mysqli_query($DB_CON,"UPDATE users SET Verified=1 WHERE Username='$USERNAME'"); it's based on the variable $USERNAME... You should check that it exists and is properly set. Quote Link to comment https://forums.phpfreaks.com/topic/286288-help-with-email-verification/#findComment-1469914 Share on other sites More sharing options...
Psycho Posted February 21, 2014 Share Posted February 21, 2014 Why do you have two tables? You state one table has a column for "verified" with a 1 or 0. Why not just use the records in that table and change that value (you'd probably just need to move the hash column there as well)? Seems like you're making this harder than it should be. But, I'm betting the problem is what WebStyles stated - the variable $Username is not set. It's always a good idea to create your queries as string variables so you can verify them if needed. $SQL_REQUEST = "SELECT * FROM `unverified` WHERE `Hash`='$Hash'"; $SQL_RESULT = mysqli_query($DB_CON, $SQL_REQUEST); $SQL_VALID = mysqli_num_rows($SQL_RESULT); if($SQL_VALID > 0){ $query = "UPDATE users SET Verified=1 WHERE Username='$USERNAME'"; echo $query; // Verify the query mysqli_query($DB_CON,$query); mysqli_query($DB_CON,"DELETE FROM `unverified` WHERE `Hash`='$Hash'"); echo '<p>Your account has been activated, you can now login <a href="https://www.site.org/login/">here</a></p>'; mysqli_close($DB_CON); exit(); } else{ die("The hash and/or username you provided was incorrect. If you believe this is an error, please contact customer support."); } Quote Link to comment https://forums.phpfreaks.com/topic/286288-help-with-email-verification/#findComment-1469923 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.