HTML表单不会通过PHP发送电子邮件

时间:2015-05-21 19:11:20

标签: php html forms email

我正在尝试建立联系页面,但表单不起作用。这是我的html和php的副本。

"Country, Long Name\xa0"

PHP:

<body>
    <h1 id="title">Joerassic Park</h1>
    <div id="navt">
        <a href="index.html">Home</a> | <a href="about.html">About Me</a> | <a href="contact.html">Contact Me</a>
    </div>
    <div id="content">
        <center>
            <form action=”contact.php” method=”post”>
                Name: <input type=”text” name=”name”>
                <br /><br />
                Email: <input type=”text” name=”email”>
                <br /><br />
                Message:
                <br />
                <textarea name=”message” rows="10" cols="30"></textarea>
                <br /><br />
            <input type="submit" value="Submit">
            </form>
        </center>
    </div>
</body>

目标是让他们填写表格然后直接给我发电子邮件结果。

1 个答案:

答案 0 :(得分:0)

您的双引号无效:

    <html>
<body>
<?php
$to = “xyz@somedomain.com”;
$subject = “Contact Form”;
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$headers = “From: $email”;
$sent = mailto($to,$subject,$name,$message,$headers);
if($sent){
print('<a href=”contact.html”>Thank you. Click here to return to site.</a>')
}else{
print “There was an issue with your contact form”;
}
?>
</body>
</html>

应该是:

    <html>
<body>
<?php
$to = "xyz@somedomain.com";
$subject = "Contact For";
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$headers = "From: $email";
$sent = mailto($to,$subject,$name,$message,$headers);
if($sent){
print('<a href="contact.html">Thank you. Click here to return to site.</a>')
}else{
print "There was an issue with your contact form";
}
?>
</body>
</html>