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.

Recommended Answers

All 2 Replies

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?

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.