我的表格行动有什么问题?

时间:2013-08-14 19:38:07

标签: html

我希望我的表单能够向我发送电子邮件,但我不确定在何处/如何编码html,以便表单中的所有字段都填充电子邮件。或者,这真的应该转到服务器端的页面吗?

这是我现有的代码。你能告诉我如何解决它吗?

 <!-- Contact Section -->
  <div class="section contact" id="contact">
    Contact
    <h2>Say hello</h2>
    <p>Whether you have a communication need to be fully developed, or a quick question for a no-charge opinion or assesment, share the goods here.</p>

    <form action="sendEmail.php" method="POST" class="myForm clearfix" autocomplate="off"> 


      <div class="form-field">

        <label for="name">Name</label>
        <input type="text" id="name">

      </div>

      <div class="form-field">

        <label for="issue">Describe your issue or opportunity </label>
        <textarea name="issue" cols="30" rows="10"></textarea>

      </div>

      <div class="form-field">

      <label for="file">Attach a file</label>
      <input type="file" id="file">

      </div>

      <div class="form-field">

      <label for="email">Email</label>
     <!--  <input type="text" id="email"> -->
      <input type="email" name="emailAddress" placeholder="Please enter your email address">

    </div>

    <div class="form-field">

      <label for="phone">Phone </label>
      <input type="text" id="phone">

    </div>

    <div class="form-field">


      I prefer to be contacted by:
      Email <input type="radio" name="contact" value="email">
      Phone <input type="radio" name="contact" value="phone">

      <!-- <form method="post" action="mailto:info@whatshouldisay.ca" >
<input type="submit" value="Submit form" />  -->

<input type="submit" value="Submit"  -->

    </div>


    </form>


  </div>

1 个答案:

答案 0 :(得分:4)

如果您想使用mailto:,只是打开用户的电子邮件客户端,并且预先填写了字段,则不使用POST表单,而是使用GET表单。

<form action="mailto:test@example.com">
    Subject: <input name="subject"><br>
    Body: <input name="body"><br>    
    <input type="submit">
</form>

Works for me.


如果您想直接从服务器发送电子邮件(完全绕过用户的电子邮件客户端),您需要set up a script来处理表单帖子。