Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form problem Tks Guys

Status
Not open for further replies.

gokeeffe

Programmer
Jan 11, 2005
170
IE
Here’s my problem I have a three step registration phase where the user will fill in text boxes and drop downs for the process.

My question is if a user would like to change some of the information after they see the results in the confirmation page what is the best way to do this.

At present I am thinking getting the user to click back to the page they want to change and then enter the new info.

The problem I am having with this method is that the fields appear blank when you go back. How can I keep these values on the forms until the submit button is actually pressed.

Here is a sample of some of the code in my forms

<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>

Hope someone can help.

Much appreciated.

Gaz
 
what u are looking for is sessions... try a search for it in this forum...

Known is handfull, Unknown is worldfull
 
I am using sessions to pass data but how to i pass it to the form can you show me with my code how to do it.
 
//The Page where you enter the data
<?
session_start();
?>
<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($_SESSION['town_region_name'])) echo stripslashes($_SESSION['town_region_name']);?>"/>
</td>
</tr>


in the page that collects the data:
<?
session_start();
$town_region_name=$_POST["town_region_name"];
$_SESSION["town_region_name"]=$town_region_name;
?>

in the page after the process is over:
<?
session_start();
session_destroy();
?>


another thing that i wanted to ask:
try this - <a href="javascript:history.back()">Back</a>

if that works then you need not use sessions...

Known is handfull, Unknown is worldfull
 
I get you know it works amazing, i think i finally

understand sessions, thanks alot vbkris (Programmer)
 
VBRIS

One last question, How can I apply this session magic to my

drop down code. How to I register the sessions using this


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();
 
i dont get you, u can capture the value in a session variable like any textbox's value...

Known is handfull, Unknown is worldfull
 
I mean is it something like this

echo "<option value=\"$_SESSIONrow[0]\">$_SESSIONrow[1] </option>\n";


How do you apply a session to an array that is coming from

a mysql database
 
while ($row = mysql_fetch_array ($query_result, MYSQL_NUM))

{
$sel="";
if($_SESSION["OptionValueVariable"]==$row[0])
$sel="selected";

echo "<option value=\"$row[0]\" $sel>$row[1]</option>\n";
}


Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top