Jump to content

PHP post forms


mcquaye

Recommended Posts

I want to be able to clear the fields after and when someone sends a form to the server mail. But instead the inpuy remains. even after refresh. This is my coding. How and what do i need to do to resolve this please.... <?php$your_email ='hello@4twentygraphicillusions.com';$errors = '';$name = '';$visitor_email = '';$subject = '';$user_message = ''; if(isset($_POST['submit'])){ $name = $_POST['name']; $visitor_email = $_POST['email']; $subject = $_POST['subject']; $user_message = $_POST['message']; //send the email $to = $your_email; $subject="New form submission"; $from = $your_email; $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''; $body = "A user $name submitted the contact form:\n". "Name: $name \n". "Email: $visitor_email \n". "Subject: $subject \n". "Message: \n ". "$user_message\n". "IP: $ip\n"; $headers = "From: $from \r\n"; if(mail($to, $subject, $body,$headers)){ $confirm = "<span id='confirm'>We've received your message. Thank You!</span>"; }else{ $error = "<span id='error'>An error occured</span>"; } } ?>

Link to comment
Share on other sites

If you're printing out the submitted values when you write the form again, then remove the code that prints the values. If you're submitting via ajax then you'll need to add some Javascript to clear the fields.

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...
I want to be able to clear the fields after and when someone sends a form to the server mail. But instead the inpuy remains. even after refresh. This is my coding. How and what do i need to do to resolve this please....
http://www.w3schools.com/tags/att_input_type.asp
<input type="reset" name="reset" value="Reset Form!">

Should work!

Link to comment
Share on other sites

he wants it cleared automatically per his requirements, not manually with the user having to click a button.

Edited by thescientist
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...