Bootstrap联系表单不是-php函数

时间:2014-11-30 05:46:07

标签: php html twitter-bootstrap contact-form

我编码了html和php但是cloudsblack84@gmail.com(邮件地址)仍然无法从我的网站(http://cloudsblack.info/)接收邮件,最后当我点击提交按钮时会进入空白页面({ {3}})。对不起,我只是网页设计的初学者需要从你们那里学到很多东西。

HTML PART

    <!-- Contact Section -->
<section id="contact" class="contacts-section">
    <div class="container content-lg">
        <div class="title-v1">
            <h2>Contact Us</h2>
            <p>I'm always happy to hear from you. Please contact or email me for appointment or service enquiry.</p>
        </div>

        <div class="row contacts-in">
            <div class="col-md-6 md-margin-bottom-40">
                <ul class="list-unstyled">
                    <li><i class="fa fa-home"></i> Kuala Lumpur</li>
                    <li><i class="fa fa-phone"></i> (6)016-7187764</li>
                    <li><i class="fa fa-envelope"></i> <a href="-removed-email-">-removed-email-</a></li>
                </ul>
            </div>

            <div class="col-md-6">
                 <form method="post" action="index.php">
                    <label>Name</label>
                    <div class="row margin-bottom-20">
                        <div class="col-md-7 col-md-offset-0">
                            <input type="text" name="name" class="form-control">
                        </div>                
                    </div>

                    <label>Email<span class="color-red">*</span></label>
                    <div class="row margin-bottom-20">
                        <div class="col-md-7 col-md-offset-0">
                            <input type="text" name="email" class="form-control">
                        </div>                
                    </div>

                    <label>City</label>
                    <div class="row margin-bottom-20">
                        <div class="col-md-7 col-md-offset-0">
                            <input type="text" name="city" class="form-control">
                        </div>                
                    </div>

                    <label>Telephone</label>
                    <div class="row margin-bottom-20">
                        <div class="col-md-7 col-md-offset-0">
                            <input type="text" name="telephone" class="form-control">
                        </div>                
                    </div>


                    <label>Interested</label>
                    <div class="row margin-bottom-20">
                        <div class="col-md-7 col-md-offset-0">
                            <input type="text" name="interested" class="form-control">
                        </div>                
                    </div>

                    <label>Message</label>
                    <div class="row margin-bottom-20">
                        <div class="col-md-11 col-md-offset-0">
                            <textarea rows="8" name="message" class="form-control"></textarea>
                        </div>                
                    </div>

                    <p><button type="submit" name="submit" class="btn-u btn-brd btn-brd-hover btn-u-dark">Send Message</button></p>
                </form> 
            </div>
        </div>            
    </div>

PHP PART

<?php
$name = $_POST['name'];
$email = $_POST['email'];
$city = $_POST['city'];
$telephone = $_POST['telephone'];
$interested = $_POST['interested'];
$message = $_POST['message'];
$submit = $_POST['submit'];

if($submit){

$from = 'From: -removed-domain-'."\r\n"; 
$to = '-removed-email-'; 
$subject = "Message from -removed-domain-";
$body = "".
    "From: ".$name."\n".
    "E-mail: ".$email."\n".
    "City: ".$city."\n".
    "Telephone: ".$telephone."\n".
    "Interested: ".$interested."\n".
    "Message: ".$message."\n";

if(mail($to, $subject, $body, $from)){
    echo '<p>Your message has been sent!</p>';
}
else{
    die('<p>Something went wrong, go back and try again!</p>'); 
}
}
?>

1 个答案:

答案 0 :(得分:0)

如果您在Something went wrong, go back and try again!内看到邮件php.ini邮件服务器配置不正确或已超时

如果您看到Your message has been sent!,请检查您的垃圾邮件文件夹。

如果所有其他方法都失败,请通过WHM或CPanel访问您的邮件服务器日志或联系您的托管服务提供商


$ submit = $ _POST [&#39;提交&#39;];

您没有给<button name='submit'>一个值,{/ 1}}在您的POST数据中是假/不存在。


仍然不是空白页面的原因,需要查看您的apache / php错误日志或询问您的托管服务提供商。