Can anyone help me with the following problem
I have a four step registration form with the fourth
page being the confirmation page where you submit the
details. My problem is this if someone wants to change
a detail or details they will click back to the appropriate
page and change the detail then move back to the conformation
page to submit the details when correct. The problem i have
is that the details are not showing up on the forms when
you click backwards, they are all blank, how can I keep them
in the form fields. I'm using session variables.
Here is the code of one of the pages.
<?php # index.php
// This is the main page for the site
// Include the configuration file for error management and such
require_once ('includes/config.inc');
// Set the title and the html header
$page_title = 'Step Two';
// Include the header file
include_once('includes/header.html');
require_once ('../mysql_connect.php'); // Connect to the Database
?>
<div id = "contentform">
<?php
if (isset($_POST['submit']))
{ // Check if the form has been submitted
if (($_POST['county_id']) == 1)
{ // Validate the secondary exam
$u4 = FALSE;
echo '<p class="validation">You forgot to select a county !</p>';
}
else
{
$u4 = escape_data($_POST['county_id']);
}
// Check for a town/region
if (eregi ("^[[:alnum:]_]{4,30}$", stripslashes(trim($_POST['town_region_name']))))
{
$u5 = escape_data($_POST['town_region_name']);
}
else
{
$u5 = FALSE;
echo '<p class="validation">Please enter a valid town/region!</p>';
}
if ($u4 && $u5)
{ // If everything is ok
// Get the users input from the form
$county_id = $_POST['county_id'];
// Start the session register the values and redirect
$_SESSION['county_id'] = $row[0];
$_SESSION['town_region_name'] = $_POST['town_region_name'];
$_SESSION['extra_location_details'] = $_POST['extra_location_details'];
ob_end_clean(); // Delete the buffer
header("Location: . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "step3.php");
//header('Location:
exit();
}
} // End Of Check if the form has been submitted
?>
<form name = "signup" id="signup" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<fieldset>
<legend>Step Two <font size="-2"><font color="#666666">County - Town - Additional</font></font></legend>
<h2>
Select County : Provides you with the option to select your county of choice</br></br>
Select Town/Region : Allows you to specify where exactly you would like to provide grinds eg. Dublin 4,Clonmel,Mallow</br></br>
Select Additional Location Details : Optional if you would like to be more specific</br>
</h2>
<?php
echo'<table align="center">';
echo'<tr>
<td colspan="2" class="labelcell"><label for="county_id">Select County:</label></td>';
echo'<td colspan="2" class="fieldcell2">
<select name="county_id">';
$query_result = mysql_query ('SELECT * FROM counties ORDER BY county_id');
while ($row = mysql_fetch_array ($query_result, MYSQL_NUM))
{
echo "<option value=\"$row[0]\">$row[1]</option>\n";
}
echo'</select></td>';
echo'</tr>';
mysql_close();
?>
<tr>
<td colspan="2" class="labelcell"><label for = "town_region_name">Town/Region</label></td>
<td colspan="2" class="fieldcell2"><input type="text" name="town_region_name" size="20" maxlength="20"
value="<?php if(isset($_POST['town_region_name'])) echo stripslashes($_POST['town_region_name']);?>"/>
</td>
</tr>
<tr>
<td colspan="2" class="labelcell"><label for = "extra_location_details">Additional Location Details</label></td>
<td colspan="2" class="fieldcell2"><input type="text" name="extra_location_details" size="100" maxlength="100"
value="<?php if(isset($_POST['extra_location_details'])) echo stripslashes($_POST['extra_location_details']);?>"/>
</td>
</tr>
</td>
</tr>
</table>
</fieldset>
<input type="submit" name="submit" value="Step Three" class="btn"/>
</br>
</br>
<?php
// Include the footer file
include_once('includes/footer.html');
?>
Please Please Help me
Tks
Gaz
I have a four step registration form with the fourth
page being the confirmation page where you submit the
details. My problem is this if someone wants to change
a detail or details they will click back to the appropriate
page and change the detail then move back to the conformation
page to submit the details when correct. The problem i have
is that the details are not showing up on the forms when
you click backwards, they are all blank, how can I keep them
in the form fields. I'm using session variables.
Here is the code of one of the pages.
<?php # index.php
// This is the main page for the site
// Include the configuration file for error management and such
require_once ('includes/config.inc');
// Set the title and the html header
$page_title = 'Step Two';
// Include the header file
include_once('includes/header.html');
require_once ('../mysql_connect.php'); // Connect to the Database
?>
<div id = "contentform">
<?php
if (isset($_POST['submit']))
{ // Check if the form has been submitted
if (($_POST['county_id']) == 1)
{ // Validate the secondary exam
$u4 = FALSE;
echo '<p class="validation">You forgot to select a county !</p>';
}
else
{
$u4 = escape_data($_POST['county_id']);
}
// Check for a town/region
if (eregi ("^[[:alnum:]_]{4,30}$", stripslashes(trim($_POST['town_region_name']))))
{
$u5 = escape_data($_POST['town_region_name']);
}
else
{
$u5 = FALSE;
echo '<p class="validation">Please enter a valid town/region!</p>';
}
if ($u4 && $u5)
{ // If everything is ok
// Get the users input from the form
$county_id = $_POST['county_id'];
// Start the session register the values and redirect
$_SESSION['county_id'] = $row[0];
$_SESSION['town_region_name'] = $_POST['town_region_name'];
$_SESSION['extra_location_details'] = $_POST['extra_location_details'];
ob_end_clean(); // Delete the buffer
header("Location: . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "step3.php");
//header('Location:
exit();
}
} // End Of Check if the form has been submitted
?>
<form name = "signup" id="signup" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<fieldset>
<legend>Step Two <font size="-2"><font color="#666666">County - Town - Additional</font></font></legend>
<h2>
Select County : Provides you with the option to select your county of choice</br></br>
Select Town/Region : Allows you to specify where exactly you would like to provide grinds eg. Dublin 4,Clonmel,Mallow</br></br>
Select Additional Location Details : Optional if you would like to be more specific</br>
</h2>
<?php
echo'<table align="center">';
echo'<tr>
<td colspan="2" class="labelcell"><label for="county_id">Select County:</label></td>';
echo'<td colspan="2" class="fieldcell2">
<select name="county_id">';
$query_result = mysql_query ('SELECT * FROM counties ORDER BY county_id');
while ($row = mysql_fetch_array ($query_result, MYSQL_NUM))
{
echo "<option value=\"$row[0]\">$row[1]</option>\n";
}
echo'</select></td>';
echo'</tr>';
mysql_close();
?>
<tr>
<td colspan="2" class="labelcell"><label for = "town_region_name">Town/Region</label></td>
<td colspan="2" class="fieldcell2"><input type="text" name="town_region_name" size="20" maxlength="20"
value="<?php if(isset($_POST['town_region_name'])) echo stripslashes($_POST['town_region_name']);?>"/>
</td>
</tr>
<tr>
<td colspan="2" class="labelcell"><label for = "extra_location_details">Additional Location Details</label></td>
<td colspan="2" class="fieldcell2"><input type="text" name="extra_location_details" size="100" maxlength="100"
value="<?php if(isset($_POST['extra_location_details'])) echo stripslashes($_POST['extra_location_details']);?>"/>
</td>
</tr>
</td>
</tr>
</table>
</fieldset>
<input type="submit" name="submit" value="Step Three" class="btn"/>
</br>
</br>
<?php
// Include the footer file
include_once('includes/footer.html');
?>
Please Please Help me
Tks
Gaz