php - Contact Form: user not returned to the form after Submit -


when user has clicked on submit button on contact form, success or error message not show on bottom part of contact form; instead message displayed on new blank page in plain format , terminates; user not returned contact form. have these 3 files contact form: contactus.html, style.css, , emailform.php.

the emailform php (this php resides on host server) contains if ($_post['submit']) { code error trapping. contactus.html contains

<form method="post" action="http://www.xxxxxx.com/emailform.php" name="form" id="form">.

can fix problem? in advance.

if after submitting form want send user previous page emailform.php file should contain:

header('location: ' . $_server['http_referer']); 

if want display error message on contactus.html add parameter url let's contactus.html?error=1, there can capture error , display user within same page.

alternatively contactus.html file ajax request emailform.php , display result within same page browser doesn't need redirect emailform.php.

if have included jquery , want post via ajax try removing action=... form, make head includes jquery , past anywhere within body:

<script type="text/javascript"> $("#submit").on("click",function(){      var email = $("#email").val();     var name = $("#name").val();     var message = $("#message").val();      $.ajax({         type: "post",         url: "/emailform.php",         data: { email : email, name : name, message: message }     }).done(function(msg) {         //update message div here         $("#message").test(msg);         alert(msg);     }); });  </script> 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -