View Full Version : retrieve data after click go back

01-23-2010, 08:22 AM

I have a Post Form , the Process File Check if user typed His Name, Email, Text..

Now if user post His Text and Forgot his Name or email He will be redierected to the form Page ,

I want the User to retrieve the data he typed instaed Having to Start Over again ..

How That Done ?

Thank you

Len Whistler
01-23-2010, 08:38 AM
Use SESSIONS or COOKIES. The value of each field would come from the SESSIONS or COOKIES, if empty then the field would be empty.


01-23-2010, 11:03 AM
or jsut run the check in the same page.


$errors = array();

if (isset($_POST['submit'])){

$name = $_POST['name'];

$email = $_POST['email'];

$phone = $_POST['phone'];

$question = $_POST['question'];

if($name == ''){

$errors[] = 'Please enter your name.';


if($email == ''){

$errors[] = 'Please enter your email.';


if($phone == ''){

$errors[] = 'Please enter your phone number.';


if(count($errors) == 0){

//if no errors run this code you enter here.



?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>


if(count($errors) > 0){

echo '<ul>';

foreach($errors as $e){

echo '<li style="color:red;"><b>' . $e . '</b></li>';


echo '</ul>';



<form action="" enctype="multipart/form-data" method="post" id="yourform">
<table cellpadding="0" cellspacing="0" border="0" width="500">
<td width="150" valign="top">Full Name <span class="required">*</span></td>
<td valign="top"><input name="name" id="name" type="text" size="25" maxlength="255"></td>
<td width="150" valign="top">Email <span class="required">*</span></td>
<td valign="top"><input name="email" id="email" type="text" size="25" maxlength="255"> </td>
<td width="150" valign="top">Phone <span class="required">*</span></td>
<td valign="top"><input name="phone" id="phone" type="text" size="25" maxlength="255"> </td>
<td width="150" valign="top">Question <span class="required">*</span></td>
<td valign="top"><textarea name="question" cols="25" rows="5"></textarea> </td>
<td width="150">&nbsp;</td>
<td valign="top"><input name="submit" type="submit" value="Send" /></td>

This will check the form and if they miss a field it will show what they missed. This is a pretty straight forward way to do it. Just add your code you want to run on success.