PHP MYSQL User Form Registration
<p>I tried to a user registration and email verification using PHP, everything responded very well but a certain point after the user has submitted the registration form then the form is posted to <code>verify.php</code> then the script will send an activation code to the user's email.</p>

<p>The error is that the moment the activation mail is sent to the user's mail box, the page should display: </p>

<blockquote>
  <p>Thank you! An email has been sent to {Form.email}. To complete your registration, click on the email verification link sent to your email address.</p>
</blockquote>

<p>Instead, it will automatically refresh the page and redirect the user to <code>registrationcomplete.php</code> page. which suppose to come after the user has verified.</p>

<p>I used the following code:</p>

<pre><code>    &lt;?php
        require ('Connections.php');
        $activationkey =  mt_rand() . mt_rand() . mt_rand() . mt_rand() . mt_rand();
        $name = mysql_real_escape_string($_POST['name']);
        $country = mysql_real_escape_string($_POST['country']);
        $state = mysql_real_escape_string($_POST['state']);
        $add = mysql_real_escape_string($_POST['add']);
        $phone = mysql_real_escape_string($_POST['phone']);
        $email = mysql_real_escape_string($_POST['email']);
        $userid = mysql_real_escape_string($_POST['userid']);
        $password = mysql_real_escape_string($_POST['password']);
        $lrname = mysql_real_escape_string($_POST['lrname']);
        $lraccount = mysql_real_escape_string($_POST['lraccount']);
        $wmz = mysql_real_escape_string($_POST['wmz']);

        $form_submitt = $_POST['button'];

        if ($form_submitt == true){


        $sql = "INSERT INTO customers (`activationkey`, `name`, `country`, `state`, `add`,    `phone`, `email`, `lrname`, `lraccount`, `comment`, `wmz`, `okpay`, `userid`, `password`,  `status`) VALUES ('$activationkey', '$name', '$country', '$state', '$add', '$phone',  '$email', '$lrname', '$lraccount', '', '$wmz', '', '$userid', '$password', 'verify');";

       mysql_query($sql) or die(mysql_error());



       ##Send activation Email

       $to      = $_POST['email'];

       $subject = "Complete registation";

       $message = "Welcome to sitename!\r\rYou, or someone using your email address, has completed registration at www.sitename.com.\r\r You can complete registration by clicking the following link:\rhttp://www.sitename.com/verify.php?$activationkey \r\rIf this is an error, ignore this email and you will be removed from our mailing list.\r\rRegards,\r\r www.sitename.com Team";

       $headers = 'From: noreply@sitename.com' . "\r\n" .

    'Reply-To: noreply@sitename.com' . "\r\n" .

    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);


}
?&gt;
&lt;?php

##User isn't registering, check verify code and change activation code to null, status to activated on success



if(isset($_SERVER['QUERY_STRING'])){

  $queryString = $_SERVER['QUERY_STRING'];

  $query = "SELECT * FROM `DBName`.`customers`"; 

  $result = mysql_query($query) or die(mysql_error());

  while($row = mysql_fetch_array($result)){

    if ($queryString == $row['activationkey']){

       $sql = "UPDATE `DBName`.`customers` SET `activationkey` = '', `status` = 'verified' WHERE `customers`.`id` = $row[id];";

       mysql_query($sql) or die(mysql_error());

       echo "&lt;meta http-equiv='refresh' content='0;url=registrationcomplete.php'&gt;";

       if (!mysql_query($sql)){

        die('Error: ' . mysql_error());

       }

    }

  }

}
?&gt;
</code></pre>
