如何让我的HTML5表单自行刷新?

时间:2013-12-26 22:02:52

标签: php html5 forms submit

我的网站上有一个联系表格,一旦你点击提交按钮,就会出现一个回音信息但是在新页面上。

我希望页面在有人点击提交时自动刷新,但也会与回显消息一起自动刷新。

这是HTML5代码:

    <form method="post" id="form" action="send3.php" class="sendmail" onsubmit="return validateForm()" style="text-align:center;">


    <!-- Form Name -->

   <center><h2 class="">Contact Us</h2>



   </div>


  <center><label class="control-label">Your Email Address</label>

  <center><input type="text" id="eadd" name="eadd" class="input-xlarge" required>




  <center><label class="control-label">Topic of Message</label>

  <center><input type="text" id="top" name="top" class="input-xlarge" required>





  <center><label class="control-label">Message</label>


  <center><textarea id="mess" name="mess" required></textarea>



  <Br>

 <!-- Button -->

 <label class="control-label"></label>

 <div class="controls">   

 <center><input class="btn btn-primary"  type="submit">

     </div>
           </form>

任何提示/ Adivce将非常感谢!

1 个答案:

答案 0 :(得分:0)

这样的声音就是你要找的......

[myContactPage.php]

if ($_SERVER['REQUEST_METHOD'] == 'POST') //Here you could check other items like referrer or some of your posted fields if you want
{
    //do whatever your current send3.php does
    //echo the result back out
}

<form method="post" id="myForm" action="myContactPage.php" onsubmit="return validateForm()">
    [email field]
    [name field]
    [message field]
    etc...
    [submit button]
</form>