dplbf4340 2014-11-29 07:03
浏览 20
已采纳

Bootstrap PHP联系表单

I had faced a problem with bootstrap PHP contact form . I using Unify theme bootstrap framework , UI is done but I wouldn't know how to make contact form function . Can anyone help and make correction for me . here my website . http://cloudsblack.info/

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="1122johnho@gmail.com">1122johnho@gmail.com</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" 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" 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" 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" 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" 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" class="form-control"></textarea>
                        </div>                
                    </div>

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

AND here is PHP part .

<?php
$Name = $_POST['name'];
$Email = $_POST['email'];
$City = $_POST['city'];
$Telephone = $_POST['telephone'];
$Interested = $_POST['interested'];
$Message = $_POST['message'];
$from = 'From: Johnhophotography.com'; 
$to = 'cloudsblack84@gmail.com'; 
$subject = 'Message from johnhophotography.com';

$body = "From: $name
 E-Mail: $email
 City: $city
 Telephone: $telephone
 Interested: $interested
 Message:
 $message";

if ($_POST['submit']) {              
    if (mail ($to, $subject, $body, $from)) { 
    echo '<p>Your message has been sent!</p>';
} else { 
    echo '<p>Something went wrong, go back and try again!</p>'; 
} 
} else if ($_POST['submit']) {
echo '<p>You answered the anti-spam question incorrectly!</p>';
}
?>

Thanks !!!

  • 写回答

2条回答 默认 最新

  • dongliu6848 2014-11-29 07:22
    关注

    Makes following changes:

    First Change:

    In your form tags just add names according to the specified name on a server.

    <input type="text" name="name" class="form-control">
    <input type="text" name="email" class="form-control">
    <input type="text" name="city" class="form-control">
    <input type="text" name="telephone" class="form-control">
    <input type="text" name="interested" class="form-control">
    <textarea rows="8" name="message" class="form-control"></textarea>
    <button type="submit" name="submit" class="btn-u btn-brd btn-brd-hover btn-u-dark">Send Message</button></p>
    

    If you want to receive your form data on a server you have to give it the same name as used it used by your server.

    Second Change:

    Make Following changes in your code:

    <?php
    //Add this two line in your code. It reports you exact problem you are facing in PHP Code.
    error_reporting(E_ALL);
    ini_set('error_reporting', E_ALL);
    
    $Name = $_POST['name'];
    $Email = $_POST['email'];
    $City = $_POST['city'];
    $Telephone = $_POST['telephone'];
    $Interested = $_POST['interested'];
    $Message = $_POST['message'];
    $from = 'From: Johnhophotography.com'; 
    $to = 'cloudsblack84@gmail.com'; 
    $subject = 'Message from johnhophotography.com';
    
    $body = "From: $name
     E-Mail: $email
     City: $city
     Telephone: $telephone
     Interested: $interested
     Message:
     $message";
    
    if ($_POST['submit']) {              
        if (mail ($to, $subject, $body, $from)) { 
            echo '<p>Your message has been sent!</p>';
        } else { 
            echo '<p>Something went wrong, go back and try again!</p>'; 
        } 
    }
    else
    {
        echo '<p>You answered the anti-spam question incorrectly!</p>';
    }
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 shape_predictor_68_face_landmarks.dat
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制