mcquaye Posted May 20, 2013 Share Posted May 20, 2013 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 More sharing options...
justsomeguy Posted May 20, 2013 Share Posted May 20, 2013 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. 1 Link to comment Share on other sites More sharing options...
mcquaye Posted May 20, 2013 Author Share Posted May 20, 2013 Can you please teach me how. Am still a noob at php Link to comment Share on other sites More sharing options...
justsomeguy Posted May 20, 2013 Share Posted May 20, 2013 Show the code that displays the form. Link to comment Share on other sites More sharing options...
MarkT Posted May 29, 2013 Share Posted May 29, 2013 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 More sharing options...
thescientist Posted June 4, 2013 Share Posted June 4, 2013 (edited) he wants it cleared automatically per his requirements, not manually with the user having to click a button. Edited June 4, 2013 by thescientist Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now