Jump to content

Confirmation Email Codes


-Karl-

Recommended Posts

<?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.

Link to comment
https://forums.phpfreaks.com/topic/198815-confirmation-email-codes/
Share on other sites

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());



}
    }
}
?>

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.