联系表单HTML到PHP

时间:2014-01-24 01:45:01

标签: php html twitter-bootstrap

获取此HTML联系表单以发送电子邮件的最简单方法是什么?

<div class="col-lg-4">
    <h4>Hire Me</h4>
    <form role="form">
        <div class="form-group">
            <input type="name" class="form-control" placeholder="Your Name">
        </div>
        <div class="form-group">
            <input type="email" class="form-control" placeholder="Your Email">
        </div>                
        <textarea class="form-control" rows="3" placeholder="Tell me about your project..."></textarea>
        <br>
        <button type="submit" class="btn btn-success">SUBMIT</button>
    </form>             
</div><!-- /col-lg-4 -->

4 个答案:

答案 0 :(得分:2)

如本回答所述:

How to create an email form that can send email using html

您无法通过HTML直接进行此操作。查看建议的答案。

答案 1 :(得分:1)

您必须使用php程序创建一个.php文件才能发送电子邮件..

你可以参考这个网站,它将展示如何做到这一点,只需调用你提交表格的php文件..

http://www.w3schools.com/php/php_mail.asp

祝你好运! :)

答案 2 :(得分:0)

将其添加到表单行      

然后创建一个名为email-sending.php的文件

<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$formcontent=" From: $name \n Email: $email \n Order Number: $order_number \n Sign Up for Newsletter: $newsletter \n Message: $message";
$recipient = "your email";
$subject = "Subject from $name";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You! We will get back to you as soon as possible!" . " -" . "<a href='./index.php'> Back to site</a>";
?>

答案 3 :(得分:0)

您可以在上面的答案中使用PHP代码,也可以使用已经“经过实战测试”的其他程序,并且使用起来更安全。

快速谷歌搜索从github给了PHPMailer:https://github.com/PHPMailer/PHPMailer