954,600 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Reload/Redirect to a form without losing data

I'm working on a contact form. I have the form being checked by a PHP script once it's submitted. If the script finds an error, it will load a new page with the error message and then redirect back to the form after 10 seconds so the user can correct the error.

The problem is that when the form reloads, it is blank.

How can I have the form reload and keep the entered data?

This is what I'm using now:

window.setTimeout("window.location = './contact.htm'", 10*1000 );

Thanks.

cableguy414
Light Poster
44 posts since Aug 2009
Reputation Points: 10
Solved Threads: 0
 

I'm working on a contact form. I have the form being checked by a PHP script once it's submitted. If the script finds an error, it will load a new page with the error message and then redirect back to the form after 10 seconds so the user can correct the error.

The problem is that when the form reloads, it is blank.

How can I have the form reload and keep the entered data?

This is what I'm using now:

window.setTimeout("window.location = './contact.htm'", 10*1000 );

Thanks.

Why not just reload the same page and display the error there instead of a separate page and use PHP to set the field values instead of javascript?

ShawnCplus
Code Monkey
Team Colleague
1,583 posts since Apr 2005
Reputation Points: 526
Solved Threads: 268
 

php code for forms
the form processor can be in the form
it can post to itself, on error output html even AT the precise point in the form that the invalid information is

<?php //form processing
?> 
<!doctype><html><head><body><form action='<?php echo $_SERVER['php_self']; ?>' method='post'>
<input value='<?php echo $_post['$fieldname']; ?>' name='fieldname'><?php if isset($fieldnameerror) {echo "html error correct instructions';} ?>

crappy code but my mind works best with examples

almostbob
Posting Sensei
3,149 posts since Jan 2009
Reputation Points: 571
Solved Threads: 376
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You