Jump to content

[SOLVED] clear form after submit


bluesmap

Recommended Posts

i have a form that i want cleared after user submits the form.  right now as it stands if the user hits the "BACK" button on the browser they are still able to see what they typed.  which sucks.

 

this is the code as i have it now.

 

<form action="mailer.php" method="post">

<input type="text" name="name" size="40"> | Name |
<br>
<br>
<input type="text" name="e-mail" size="40"> | eMail |
<br>
<br>
<input type="text" name="subject" size="40"> | Subject |
<br>
<br>
<br>
<textarea name="message" rows="8" cols="60"> </textarea>
<br>
<br>
<input type="submit" value="Send">       | |       <input type="reset" value="Cancel">


</form>

 

i have a "mailer.php" that handles sending the data to me via email.

how would i go about having he form cleared after user hits the "send" button?

 

also, what characters should i be restricting in the form?? i was advised to restrict certain symbols and characters from being typed into the form.....

 

so those two questions if anyone has some insight that would be great.

Link to comment
Share on other sites

Take a look at possible cache-control values you can set using the header() function. I will usually set cache-control to private just to get the exact issue you are having. I typically want user's to be able to go back and have the contents present.

 

This should do what you want (must be at top of the page)

 

header("Cache-Control: no-cache, must-revalidate");

 

As to what characters to allow I would stick with just a basic character set (lower/upper case letters, numbers, and some basic special characers. It's much easier to use a white list than a black list. Use a resgular expression client-side and server side to restrict the character set.

Link to comment
Share on other sites

can you tell me what that is saying....just so i understand?  i havent gotten around to knowing that much about the cache and what that function is executing.  although the form is doing what i want it to do.  i appreciate the response and i thank you very much.

 

 

Link to comment
Share on other sites

The cache is a temporary storage of pages you view and data that you have entered. The above command tells the browser that the page should not be cached, so when you hit the back button it must reload the page from scratch.

 

I'd like to note that the practical advantages aren't only related to the back button. It also helps when you have to refresh a page, or in one case I recently encountered, when you have a plain text file modified by a JS script.

 

And sarcasm is difficult to communicate through simple text. There are precious few instances when sarcasm is appropriate, and this is not one of them.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.