Jump to content

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

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.