Hi and thanks for looking.
The code below is my signup page and it all goes fine until i have to compare the code i sent to their email address with the code they copy into a textbox. It works but only on when you submit the form and then ALSO refresh the page.
I have spent days on this and just can't see how to fix it. Any tips at all would be great. Sorry the code probably is the greatest, but i'm just starting out so I'll have time to fix it up.
BTW the site page can be viewed at http://www.thinksane.net/signup.php
Thanks again for looking
----------------------------------------------------------------------
<?php
if ((isset($_POST[submitcheck])) && (
(isset($_POST[regusername])) || ($_POST[regusername] != "") ||
(isset($_POST[regpassword])) || ($_POST[regpassword] != "") ||
(isset($_POST[regpasswordcheck])) || ($_POST[regpasswordcheck] != "") ||
(isset($_POST[firstname])) || ($_POST[firstname] != "") ||
(isset($_POST[surname])) || ($_POST[surname] != "") ||
(isset($_POST[dob])) || ($_POST[dob] != "") ||
(isset($_POST[country])) || ($_POST[country] != "") ||
(isset($_POST[regemail])) || ($_POST[regemail] != "") ||
(isset($_POST[agree])) || ($_POST[agree] != false) ))
{
$regusername = $_POST[regusername];
$regpassword = md5($_POST[regpassword]);
$firstname = $_POST[firstname];
$surname = $_POST[surname];
$dob = $_POST[dob];
$country = $_POST[country];
$regemail = $_POST[regemail];
setcookie("registration[username]", $regusername);
setcookie("registration[password]", $regpassword);
setcookie("registration[firstname]", $firstname);
setcookie("registration[surname]", $surname);
setcookie("registration[dob]", $dob);
setcookie("registration[country]", $country);
setcookie("registration[regemail]", $regemail);
header('location:signup.php');
}
if ( (isset($_POST[activationsubmit])) ) {
setcookie("activationstatus", "code already sent");
}
include 'php_includes/header.php';
pagetitle(Signup);
?>
<div class="container">
<div class="content">
<?php
if ((!isset($_COOKIE['registration'])) ){
?>
<h3>Follow the steps below to signup and help promote rational thought. Replace this text with step by step image showing user at what stage they are at in the signup process.</h3>
<form id="signup" name="signup" action="<?php $_SERVER['PHP_SELF'] ?>" method="POST">
<input name="submitcheck" type="hidden" value="1" />
<div>All information is required and must be entered. </div>
<div id="signupinputs">
<ol id="1">
<li><input id="username" name="regusername" type="text" />
<?php if ( (isset($_POST[submitcheck])) && ((!isset($_POST[regusername])) || ($_POST[regusername] == "")) ) {
echo '//Error on username'; }
?></li>
</ol>
<ol id="2">
<li><input id="password" name="regpassword" type="password"/>
<?php if ( (isset($_POST[submitcheck])) && ((!isset($_POST[regpassword])) || ($_POST[regpassword] == "")) ) {
echo '//Error on password'; }
?></li>
</ol>
<ol id="3">
<li><input id="passwordcheck" name="regpasswordcheck" type="password"/>
<?php if ( (isset($_POST[submitcheck])) && ((!isset($_POST[regpasswordcheck])) || ($_POST[regpasswordcheck] == "")) ) {
echo '//Error on password'; }
?></li>
</ol>
<ol id="4">
<li><input id="firstname" name="firstname" type="text" /></li>
</ol>
<ol id="5">
<li><input id="surname" name="surname" type="text" /></li>
</ol>
<ol id="6">
<li><input id="dob" name="dob" type="text"/></li>
</ol>
<ol id="7">
<li><input id="country" name="country" type="text"/></li>
</ol>
<ol id="8">
<li><input id="regemail" name="regemail" type="text"/>
<?php if ( (isset($_POST[submitcheck])) && ((!isset($_POST[regemail])) || ($_POST[regemail] == "")) ) {
echo '//Error on username'; }
?></li>
</ol>
<ol>
<li><?php if ( (isset($_POST[submitcheck])) && ((!isset($_POST[agree])) || ($_POST[agree] == false)) ) {
echo '//Error on TOS'; }
?></li>
</ol>
</div><!--Close signupinputs-->
<div id="signuptext">
<ol id="1">
<li><img src="images/1.png" /></li>
<li>Username:</li>
</ol>
<ol id="2">
<li><img src="images/2.png" /></li>
<li>Password: </li>
</ol>
<ol id="3">
<li><img src="images/3.png" /></li>
<li>Retype Password: </li>
</ol>
<ol id="4">
<li><img src="images/4.png" /></li>
<li>Firstname: </li>
</ol>
<ol id="5">
<li><img src="images/5.png" /></li>
<li>Surname: </li>
</ol>
<ol id="6">
<li><img src="images/6.png" /></li>
<li>D.O.B: </li>
</ol>
<ol id="7">
<li><img src="images/7.png" /></li>
<li>Country: </li>
</ol>
<ol id="8">
<li><img src="images/8.png" /></li>
<li>Email address: </li>
</ol>
</div><!--Close signup text-->
<ol id="9">
<li><img src="images/9.png" /></li>
<li>I agree to the TOS:</li><input id="agree" name="agree" type="checkbox" /><li>
</ol>
<ol id="9">
<li><input type="image" src="images/tick.gif" id="login" name="login" /></li>
</ol>
</form>
<?php
}
if ( (isset($_COOKIE['registration'])) && (!isset($_COOKIE['activationstatus'])) && (!isset($_POST[activationsubmit])) ) {
echo '<h1>first if statement</h1>';
$activationcode = rand(100000, 1000000);
$to = $_COOKIE[registration][regemail];
$subject = "ThinkSane.net activation code, IMPORTANT!";
$email = 'admin@thinksane.net';
$message = 'Your activation code is ' . $activationcode . '. Copy this code and paste it into the textbox back on the registration page.
You will receive another confirmation email once you are fully signed up.';
$headers = "From:" . $email;
$sent = @mail($to,$subject,$message,$headers);
if ($sent) {
echo '<h3>An email has been sent to ' . $_COOKIE['registration']['regemail'] . ' with an activation code in it. <br />
You must enter that code below before your account is created </h3>';
?>
<form id="activation" name="activation" action=<?php echo $_SERVER["PHP_SELF"]; ?> method="POST">
<p>Enter the activation code sent in the email: <input name="submittedactivationcode" type="text" />
<input name="activationcode" type="hidden" value="<?php echo $activationcode ?>" />
<input name="activationsubmit" type="submit" /></p>
</form>
<?php
}
else{
echo '<h2>The email could not be sent. You entered the address;' . $_COOKIE[registration][regemail] . '. Is that the right address?</h2>';
}
}
if ( ($_COOKIE['activationstatus'] == 'code already sent') && ( $submittedactivationcode == $activationcode ) ) {
$submittedactivationcode = $_POST[submittedactivationcode];
$activationcode = $_POST[activationcode];
if ( $submittedactivationcode == $activationcode ) {
echo '<h2>Two codes are the same, creating and running SQL</h2>';
/*$sql = "";
$result = @mysql_query($sql) or die(mysql_error());*/
}
else{
echo '<h2>The codes do not match, please check the code sent and try again.</h2>';
?>
<form id="activation" name="activation" action=<?php echo $_SERVER["PHP_SELF"]; ?> method="POST">
<p>Enter the activation code sent in the email: <input name="submittedactivationcode" type="text" />
<input name="activationsubmit" type="submit" /></p>
</form>
<?php
}
}
/*else{
echo "<p>There was a problem sending the activation code. Please make sure you supplied the right email address.</p>";
}*/
?>
</div><!--Close content div tag-->
</div><!--Close container div tag-->
<div class="footer">
<?php
include 'php_includes/footer.php';
?>
</div>
</body>
</html>