943,083 Members | Top Members by Rank

Ad:
Jan 12th, 2010
0

Reload/Redirect to a form without losing data

Expand Post »
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:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. window.setTimeout("window.location = './contact.htm'", 10*1000 );
Thanks.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
cableguy414 is offline Offline
44 posts
since Aug 2009
Jan 12th, 2010
0
Re: 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:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. 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?
Sponsor
Reputation Points: 520
Solved Threads: 268
Code Monkey
ShawnCplus is offline Offline
1,564 posts
since Apr 2005
Jan 12th, 2010
0
Re: Reload/Redirect to a form without losing data
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 Syntax (Toggle Plain Text)
  1. <?php //form processing
  2. ?>
  3. <!doctype><html><head><body><form action='<?php echo $_SERVER['php_self']; ?>' method='post'>
  4. <input value='<?php echo $_post['$fieldname']; ?>' name='fieldname'><?php if isset($fieldnameerror) {echo "html error correct instructions';} ?>
  5.  
crappy code but my mind works best with examples
Reputation Points: 561
Solved Threads: 365
Posting Maven
almostbob is offline Offline
2,964 posts
since Jan 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: external link within a popup
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: Cool Gallery Idea... where to begin?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC