Hi everyone,
I have a signup.php file which contains a whole bunch of fields that users put details into when they are registering for my website. When the click the submit button, it goes to validate.php to validate all the fields are valid (i.e -> not empty etc etc).
So when the user clicks submit it goes to validate.php, I get all the variables from the first page by doing something like this.
$_SESSION['phpFirstName'] = $_POST['htmlFirstName'];
etc
etc
If there is an error, I want to go back to the signup.php page and notify the user of the offending fields on the form. Say the user didn't fill in the first name, I would return to the signup page like this:
header("location:http://address/signup.php?errors=firstname");
when I go back to the signup.php page, I expect that all other variables that passed validation have been "session"ized and that I can display them in the form without the user having to fill them in again - however the session variable doesn't seem to work and there is nothing in there when i return.
How can this be???
Maintaining state seems to be a problem - hmmmm???
Moderator: General Moderators
Hi jshpro2,
Here is a snippet of signin.php
<form name="frmSignup" method="post" action="validate.php">
<input type="hidden" name="blnFirstTime" value="False">
<p><strong><font color="#CC00CC">Personal Details</font></strong></p>
<table width="700" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="24">Please enter a username</td>
<td><input type="text" name="txtboxUsername" value="<?php print($_SESSION['strUsername']) ?>"></td>
</tr>
<tr>
<td height="24">Please enter a password <font size="2"><em>(must be at least
6 characters long)</em></font></td>
<td><input type="password" name="textfield18"></td>
</tr>
<tr>
<td height="24">Retype your password</td>
<td><input type="password" name="textfield19"></td>
</tr>
<tr>
<td width="349" height="24">First Name</td>
<td width="356"><input type="text" name="txtboxFirstName" value="<?php print($_SESSION['strFirstName']) ?>"></td>
</tr>
<tr>
<td>Last Name</td>
<td><input type="text" name="txtboxLastName" value="<?php print($_SESSION['strLastName']) ?>"></td>
</tr>
<tr>
In validate.php, I have
<?php
$errors = "";
if(empty($_POST['txtboxUsername']))
$errors = $errors . "username" . "+";
else
$_SESSION['strUsername'] = $_POST['txtboxUsername'];
and so on.......
down the bottom I have
if($errors <> "")
header("location:http://localhost:81/clubsuntory/signup.php?errors=" . $errors);
else
header("location:http://localhost:81/clubsuntory/signup.php");
?>
Thanks a lot for helping out.
Here is a snippet of signin.php
<form name="frmSignup" method="post" action="validate.php">
<input type="hidden" name="blnFirstTime" value="False">
<p><strong><font color="#CC00CC">Personal Details</font></strong></p>
<table width="700" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="24">Please enter a username</td>
<td><input type="text" name="txtboxUsername" value="<?php print($_SESSION['strUsername']) ?>"></td>
</tr>
<tr>
<td height="24">Please enter a password <font size="2"><em>(must be at least
6 characters long)</em></font></td>
<td><input type="password" name="textfield18"></td>
</tr>
<tr>
<td height="24">Retype your password</td>
<td><input type="password" name="textfield19"></td>
</tr>
<tr>
<td width="349" height="24">First Name</td>
<td width="356"><input type="text" name="txtboxFirstName" value="<?php print($_SESSION['strFirstName']) ?>"></td>
</tr>
<tr>
<td>Last Name</td>
<td><input type="text" name="txtboxLastName" value="<?php print($_SESSION['strLastName']) ?>"></td>
</tr>
<tr>
In validate.php, I have
<?php
$errors = "";
if(empty($_POST['txtboxUsername']))
$errors = $errors . "username" . "+";
else
$_SESSION['strUsername'] = $_POST['txtboxUsername'];
and so on.......
down the bottom I have
if($errors <> "")
header("location:http://localhost:81/clubsuntory/signup.php?errors=" . $errors);
else
header("location:http://localhost:81/clubsuntory/signup.php");
?>
Thanks a lot for helping out.