Jump to content

Help with email verification


elijahkan14

Recommended Posts

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.

Link to comment
Share on other sites

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.");
        }
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.