Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
How do I clear a form after it submits?
Old 12-20-2010, 11:19 PM How do I clear a form after it submits?
Average Talker

Posts: 19
Trades: 0
I have an email form that is sending perfectly but when I send it, I get the Message "Thank you for your Submission" but it also reloads the form again right after it. How can I have the form submit, but only respond with the "success" message instead of the form again too?

Here is the PHP for the form:

PHP Code:
<?php 



    
if($_POST){
    
    
$to $_POST['First_and_Last_Name'];
    
$subject "WHAT SHOULD THIS BE";    
    
$message  =  "Blah blah blah. Blah blah blah. Blah blah blah. Blah blah blah. Blah blah blah."\n\r".
                "
Sincerely,\n".
                "
From" .$_POST['from']. "\n". 
                "
Street" .$_POST['street']. "\n".
                "
City" .$_POST['city']. "\n".
                "
Zip" .$_POST['zip']. "\n".
                "
Email" .$_POST['email']. "\n".
    
$headers = "From" .$_POST['from']. "<".$_POST['email'].">"."\n";
    mail(
$to$subject$message$headers);
    // SUCCESS!
    echo '<p class="
notice">'.
        'Thank you for your submission.  '.
          '</p>';
    // clear out the variables for good-housekeeping
    unset(
$date,$name,$street,$city,$zip,$email);
    
$_POST = array();
}
?>
Why does the form load again after submission?
lazerbrains is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-21-2010, 10:48 AM Re: How do I clear a form after it submits?
prasanthmj's Avatar
Experienced Talker

Posts: 42
Name: Prasanth
Trades: 0
Instead of echo "Thank you..." redirect to a thank you page
PHP Code:
header("Location: thankyou.html"); 
This PHP form tutorial will be useful
prasanthmj is offline
Reply With Quote
View Public Profile
 
Old 12-21-2010, 11:08 AM Re: How do I clear a form after it submits?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
PHP Code:
 if($_POST){
....

} else {

Show the form here


__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-22-2010, 06:32 PM Re: How do I clear a form after it submits?
orionoreo's Avatar
Ultra Talker

Posts: 335
Name: Jerry
Trades: 0
i've also used unset($POST); before... but all I needed then was to clear the form
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
orionoreo is offline
Reply With Quote
View Public Profile
 
Old 12-23-2010, 03:16 PM Re: How do I clear a form after it submits?
Physicsguy's Avatar
404 - Title not found

Posts: 920
Name: Scott Kaye
Location: Ontario
Trades: 0
To clear the actual contents of the form?

<input type="reset"/>
__________________
Check out my
Please login or register to view this content. Registration is FREE
or my
Please login or register to view this content. Registration is FREE
!
Physicsguy is offline
Reply With Quote
View Public Profile
 
Old 12-27-2010, 04:40 AM Re: How do I clear a form after it submits?
pedala's Avatar
Junior Talker

Latest Blog Post:
Starea vremii la Fetesti v.3
Posts: 4
Name: Ivanciu Vlad
Location: Romania
Trades: 0
or set <input autocomplete=off !

I don`t realy understand what you want. But `autocomplete` tag will be usefull.

Last edited by pedala; 12-27-2010 at 04:47 AM..
pedala is offline
Reply With Quote
View Public Profile Visit pedala's homepage!
 
Old 12-27-2010, 10:21 AM Re: How do I clear a form after it submits?
Average Talker

Posts: 18
Name: David
Location: Sweden
Trades: 0
Chrishirst is the one that's correct out of all these posters. Follow his recommendation.
__________________

Please login or register to view this content. Registration is FREE
- View random youtube videos easily & instantly!


Please login or register to view this content. Registration is FREE
- Dubstep.nu recommends great dubstep songs everyday!
FlyHour is offline
Reply With Quote
View Public Profile Visit FlyHour's homepage!
 
Reply     « Reply to How do I clear a form after it submits?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.25765 seconds with 12 queries