bluesmap Posted April 13, 2007 Share Posted April 13, 2007 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 https://forums.phpfreaks.com/topic/46805-solved-clear-form-after-submit/ Share on other sites More sharing options...
Psycho Posted April 13, 2007 Share Posted April 13, 2007 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 https://forums.phpfreaks.com/topic/46805-solved-clear-form-after-submit/#findComment-228190 Share on other sites More sharing options...
bluesmap Posted April 13, 2007 Author Share Posted April 13, 2007 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 https://forums.phpfreaks.com/topic/46805-solved-clear-form-after-submit/#findComment-228311 Share on other sites More sharing options...
Psycho Posted April 13, 2007 Share Posted April 13, 2007 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. Link to comment https://forums.phpfreaks.com/topic/46805-solved-clear-form-after-submit/#findComment-228676 Share on other sites More sharing options...
bluesmap Posted April 14, 2007 Author Share Posted April 14, 2007 topic solved. Link to comment https://forums.phpfreaks.com/topic/46805-solved-clear-form-after-submit/#findComment-228962 Share on other sites More sharing options...
neylitalo Posted April 14, 2007 Share Posted April 14, 2007 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 https://forums.phpfreaks.com/topic/46805-solved-clear-form-after-submit/#findComment-228980 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.