Jump to content

Sve POST data


karimali831

Recommended Posts

Hi,

 

When a user makes a mistake and they go back to the form, all fields are cleared.

How can I make it so that when they go back to the form, the data is still inputted?

 

Here is what I got:

 

     if($_POST['name']=="") $error_array[] = 'You must enter a title';
     if($_POST['info']=="") $error_array[] = 'You must describe the bug';
     if($_POST['filename']=="" || $_POST['filename']==".php") $error_array[] = 'You must specify the filename. e.g. cups.php';
     if($_POST['errorlocation']=="" || $_POST['errorlocation']=="http://") $error_array[] = 'You must specify the location of this bug, if not, specify your website';
 if(count($error_array)) 
 {
	$error=implode('<br />&#8226; ', $error_array);
	$showerror = '<div class="errorbox">
	  <b>Please fix the following error(s):</b><br /><br />
	  &#8226; '.$error.'
	</div>';
	echo $showerror.'<br /><input type="button" class="button" onClick="javascript:history.back()" value="Go Back">';

      }else{ mysql_query() }

 

Any help is appreciated,

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/208835-sve-post-data/
Share on other sites

You can achieve this a number of ways. If the content is not private then you could put the data into the URL. Or you could put the data in SESSION variable. When the check php goes back to the form page, the form page gets the data from where ever you put in it and inputs it into the form fields.

 

e.g. name field

$name = "";

if(isset($_GET['name']))
  {
    $name = $_GET['name'];
  }
echo "<input type=\"text\" name=\"name\" value=\"$name\"/>";

Link to comment
https://forums.phpfreaks.com/topic/208835-sve-post-data/#findComment-1090910
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.