GoDaddy php mail()不会提交

时间:2016-02-22 02:23:57

标签: php

首先,我不经常使用StackOverflow,所以请耐心等待。

无论如何,我正在与客户一起构建一个简单的PHP联系表单。问题是它没有提交。有什么东西丢失了吗?我们目前正在使用GoDaddy进行托管。

<form id="main-contact-form" class="contact-form" name="contact-form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" role="form">
    <div class="row">
        <div class="col-sm-5">
            <div class="form-group">
                <input type="text" name="name" class="form-control" required="required" placeholder="First Name">
            </div>
            <div class="form-group">
                <input type="text" name="surname" class="form-control" required="required" placeholder="Surname">
            </div>
            <div class="form-group">
                <input type="text" name="email" class="form-control" required="required" placeholder="Email address">
            </div>
            <div class="form-group">
                <button type="submit" name="submit" class="btn btn-primary btn-lg">Send Message</button>
            </div>
        </div>
        <div class="col-sm-7">
            <textarea name="message" id="message" required="required" class="form-control" rows="8" placeholder="Message"></textarea>
        </div>
    </div>
</form> 


<?php
if(isset($_POST['submit'])){
    $headers = "From: ".$_POST['email']."" . "\r\n";
    //$body = $_POST['name']."<br>".$_POST['surname']."<br>".$_POST['message']."<br>"; 
    $body = $_POST['name']."<br>".$_POST['surname']."<br>".$_POST['message']."<br>"; 
    mail("xxxx@gmail.com", "New Inquiry", $body, $headers);
    echo $_POST['email'];
}
?>

提前致谢。

2 个答案:

答案 0 :(得分:0)

您检查$_POST['submit']但未实际发送。

您需要为提交按钮指定值:

 <button type="submit" value="submit" name="submit" class="btn btn-primary btn-lg">Send Message</button>

答案 1 :(得分:-1)

在标题中添加SELECT cat.id, cat.name, cat.parent_id AS `parent_id`, COUNT(pc._products_id) AS `num` FROM `categories` AS `cat` INNER JOIN `products_categories` AS `pc` ON pc.categories_id=cat.id GROUP BY cat.id HAVING COUNT(pc.products_id)>0 ,如下所示:

if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
    document.getElementById("myAnchor").href = "mobile-url";   //change url
    document.getElementById("myAnchor").target = "_blank";     //change target
}

X-Mailer标头标识创建电子邮件的软件。我不太确定,可能依赖于我们需要使用的服务器php版本。