Hi All,
questions is , on one page, there is zip code field with 'continue' button below it.
On other page, other form fields are , first name, last name, address, email and zip code fields with submit button.
What I want to do:
When customer enters zip code on first page and press continue button, the zip code field on other page already takes value from first page and customer enters remaining information and press submit button, so that all data goes into mysql database.
Could anyone help, how to do this?
Kind Regards
php form problem...
Moderator: General Moderators
-
rahulzatakia
- Forum Commoner
- Posts: 59
- Joined: Fri Feb 05, 2010 12:01 am
- Location: Ahmedabad
Re: php form problem...
hi, check out the following code which will solve your problem
File : form1.php
File : form2.php
File : form1.php
Code: Select all
<form id="form1" name="form1" method="post" action="form2.php">
Zip Code : <label>
<input type="text" name="zip" />
</label>
<label>
<input type="submit" name="Submit" value="Submit" />
</label>
</form>
Code: Select all
<form id="form2" name="form2" method="post" action="">
<table width="50%" border="1">
<tr>
<td><label>First Name </label></td>
<td><label>
<input name="fname" type="text" id="fname" />
</label></td>
</tr>
<tr>
<td>Last Name </td>
<td><label>
<input name="lname" type="text" id="lname" />
</label></td>
</tr>
<tr>
<td>Address</td>
<td><label>
<input name="address" type="text" id="address" />
</label></td>
</tr>
<tr>
<td>City</td>
<td><label>
<input name="city" type="text" id="city" />
</label></td>
</tr>
<tr>
<td>Zip Code </td>
<td><label>
<input name="zipcode" type="text" id="zipcode" value="<?=$_POST['zip']; ?>"/>
</label></td>
</tr>
<tr>
<td> </td>
<td><label>
<input type="submit" name="Submit2" value="Submit" />
</label></td>
</tr>
</table>
</form>
Re: php form problem...
Hi,
first.php
second.php
Should do the trick. Be warned though the above very simple example is open to abuse as the contents of zip aren't validated which they should be before being output to the screen let alone be written to a database without being sanitised.
HTH,
Cheers,
Dave.
first.php
Code: Select all
<form action="second.php" method="post">
Zip Code: <input type="text" name="zip"> <input type="submit" value="Proceed">
</form>Code: Select all
<form action="complete.php" method="post">
All other fields....
<?php
echo "Zip Code: ";
echo "<input type=\"text\" name=\"zip\" value=\"".$_REQUEST['zip']."\">";
?>
<input type="submit" value="Complete">
</form>HTH,
Cheers,
Dave.
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: php form problem...
You really should put the zip input box on the same page as the other stuff. There are very few situations where multi-page forms should be used. This probably isn't one of them.
Cheers
Cheers