PDA

View Full Version : is there a way to clear the form....


rancher
6-13-02, 12:51 AM
after somebody hits the send button? I have it redirect to a thank
you page, but if you hit the back button the info is still in the form.
It's secure when they fill it out, but I'd rather it flushed away
after they send.......any help is appreciated.

Rancher

rdanner3
6-13-02, 02:23 PM
I'm no expert on this, but I think you need to tell the remote system not to cache the data. Unfortunately, I'm pretty new at this myself.

SimCoWeb
6-13-02, 02:49 PM
One way is to use the javascript 'history' method, place a big 'ol link on your Thanks page that says 'click here to return to the previous page'. It will reload the page if they click on the link, thereby refreshing the form and eliminating the data.

rancher
6-13-02, 03:46 PM
I really don't want them to have to return to the forms page.
I'd rather they continued snooping around my site and that's why the link I now have takes them back to my toc. Any other way?

Thanks!
Rancher

rdanner3
5-17-05, 12:55 PM
I really don't want them to have to return to the forms page.
I'd rather they continued snooping around my site and that's why the link I now have takes them back to my toc. Any other way?There's a way (can't recall the exact syntax) to force a browser not to cache a page...think it's a header directive in the meta-tags? Someone with more experience can let us both know...since I'm sure my own form has the same problem.

(Thanks for the heads-up, albeit a bit late due to apparent goofs in the notification system.)

dirque
6-7-05, 06:11 PM
One technique involves a bit of javascript and a second form. You create a hidden form with the kind of data as your current one. When they hit submit on the visible form it calls a javascript that writes the data from the visible form to the hidden form and then CLEARS the visible form. Here is sample code. You gotta get your own datamumger.pl to make this work. :-)

<html>
<head>
<script>
function xfername ()
{
document.senddata.theirname.value = document.getdata.theirname.value;
document.getdata.theirname.value = "";
document.senddata.submit();
}
</script>
</head>
<body>
<!-- visible form -->
<form name="getdata">
<p>What is your name? <input type="text" name="theirname"></p>
<input type="button" name="submit" value="Submit" onClick="xfername()">
</form>
<!-- invisible form -->
<form name="senddata" method="post" action="datatmunger.pl">
<input type="hidden" name="theirname" value="">
</form>
</body>
</html>

Kays
6-7-05, 11:11 PM
You can find info on using the meta tags here (http://www.htmlgoodies.com/beyond/reference/article.php/3472881)

An other option might be to open the thank you page in a new window and to close the window the forum is in.

Sietse
6-8-05, 06:02 AM
This is what I'm using at work for a web application that isn't allowed any page caching:
<meta http-equiv="Expires" content="Mon, 26 Jul 1997 05:00:00 GMT">
<meta http-equiv="Cache-Control" content="no-store, no-cache, must-revalidate">
<meta http-equiv="Cache-Control" content="post-check=0, pre-check=0">
<meta http-equiv="Pragma" content="no-cache">
It is ofcourse always up to the browser to actually obey these meta tags. No matter what you do there is no 100% guarantee that it's impossible to return to the fully filled in form; if you're worried about your visitors submitting a form more than once you could, for example, use a cookie to prevent flooding...

rdanner3
6-8-05, 01:51 PM
(By the way, this is, in no way, an attempt to hijack this thread. Moderators, feel free to move it to a new topic if needed.)

No matter what you do there is no 100% guarantee that it's impossible to return to the fully filled in form; if you're worried about your visitors submitting a form more than once you could, for example, use a cookie to prevent flooding...I can't tell you how many times I've had a form malfunction (on other sites) and on hitting the Back button (or going back by whatever means) the form reloaded totally empty. I expect, however, that you're right here, and the code you show is the key to the behavior I saw, especially since I also didn't see the filled in form in my cache on browsing it with a cache-explorer.

In my case, the form I'm using is so complex (number of fields-wise) that it is imperative that the user get an exact copy back via e-mail (said email forms the basis for their character's biographical information), which is why I still use an outside script, rather than the "approved" version of formmail (which doesn't have "email-to-multiple" capability to my knowledge).

Another issue in my case (as I expect it is with many who aren't experts in coding!) is the problem of validation of critical fields. Most of my form is free-form information (Hey, it's an application to a PBeM sim! LOL) but it'd be nice if I could validate critical fields (email address, etc.) without tons of code. I've actually coded a Javascript-based form (for testing) that does work, but the bloomin' thing is relatively huge (well over 60k for the one page) and that is unacceptable, in my opinion. (the form I refer to is at http://resurrection.rhemuthcastle.com/join.html and has been for a long time.) Speed of downloading is not as critical as it once was to many, but I know a lot of people (even here in the States) who are still using the Internet at speeds as low as 26.4kbits/sec (not because of their modem, but the crappy quality of phone lines in too many areas!) and long download waits are unacceptable. :)

Sietse
6-9-05, 05:34 AM
I can't tell you how many times I've had a form malfunction (on other sites) and on hitting the Back button (or going back by whatever means) the form reloaded totally empty. I expect, however, that you're right here, and the code you show is the key to the behavior I saw, especially since I also didn't see the filled in form in my cache on browsing it with a cache-explorer.The method I described above is used with a payment system where the form data should always reflect its current state. This way, if you think you have a form malfunction and the form wasn't processed, you can hit the back button and either get the form back (properly filled, naturally), or get a message that the form was already processed and you should not hit the back button so soon there mister, thank you so very much.

As far as I know, you'll never see the page in your cache with the data you filled in; only pre-filled data is shown since they're part of the html. The fields you fill in are stored in memory.

... the problem of validation of critical fields.
...
I've actually coded a Javascript-based form (for testing) that does work, but the bloomin' thing is relatively huge (well over 60k for the one page) and that is unacceptable, in my opinion.60K in code?! That's quite a lot for form checking. Javascript for form validation is nice for pre-checks but it can be turned off all too easily to rely on it for validation purposes. Even though you say you're not an expert coder, I would at least try to make that form validation work on the server side as well. Coding in PHP is easier than javascript, IMNSHO. While you're on that, try looking into regular expressions; validating email addresses for instance can be done like this:function validateEmail ($email)
// Validates an email address
// returns empty string when valid, error message if not
// Usage:
// $emailReturn = validateEmail($email);
// $emailValid = ($emailReturn == '');
// echo $emailReturn;
{
if (strlen($email) > 0)
{
if (preg_match('/^[-_a-z0-9]+(\.[-_a-z0-9]+)*@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]{2,6}$/i',$email))
return '';
else
return 'Invalid email address';
} // if
return 'Empty email address';
} //validateEmail

// end of code
Short, clean and, if you're a geek like me, easy.