表格未填写表格并返回空白页面

时间:2018-05-28 02:20:42

标签: php mysql

这是我正在尝试用来将表单写入表格的HTML和PHP代码 按下提交后,它会加载PHP,但它会以空白屏幕的形式返回 任何帮助将不胜感激,以帮助我从这个问题前进。

以下是页面联系部分的HTML代码。

  </div>
        <!-- Contact Info -->
        <div class="row">

            </div> <!-- information end -->
            <!--Contact Form-->
            <div class="col-md-8 col-md-offset-2 wow fadeInUp" data-wow-delay="1s">
                <form class="col-md-12 contact-form" method="POST" action="beerewarded.php">
                    <div class="row">
                        <!--Name-->

                         <!--Email-->
                        <div class="col-md-8">
                            <input id="Email_Address" name="Email_Address" class="form-inp requie" type="text" placeholder="Email">
                        </div>

                        <div class="col-md-8">
                            <input id="First_Name" name="First_Name" class="form-inp requie" type="text" placeholder="First Name">
                        </div>

                          <div class="col-md-8">
                            <input id="Last_Name" name="Last_Name" class="form-inp requie" type="text" placeholder="Last Name">
                        </div>

                          <div class="col-md-8">
                            <input id="Phone_Number" name="Phone_Number" class="form-inp requie" type="text" placeholder="Phone Number">
                        </div>

                          <div class="col-md-8">
                            <input id="Birthday" name="Birthday" class="form-inp requie" type="date" placeholder="Birthday ">
                        </div>



                   <div class="col-md-12">
                            <input id="con_submit" class="site-button" type="submit">
                        </div>
                    </div>
                </form>
            </div> <!-- contact form end -->

这是该文件的PHP部分。

     <?php
 $servername = "localhost";
 $username = "beeskneesbars_com";
 $password = "123456";
 $dbname = "beeskneesbars_com";

 // Create connection
$conn = new mysqli($servername, $username, $password);

 // Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
} 

if(isset($_POST['insert'])) {
$Email_Address = $_POST['Email_Address'];
 $First_Name = $_POST['First_Name'];
 $Last_Name = $_POST['Last_Name'];
 $Phone_Number = $_POST['Phone_Numebr'];
 $Birthday = $_POST['Birthday'];


 $insert_data = mysql_query('INSERT INTO Bee_Rewarded VALUES("$Email_Address", "$First_Name","$Last_Name","$Phone_Number","$Birthday",)');

 echo "Data are successfully save..."; }
         ?>

1 个答案:

答案 0 :(得分:0)

请记住,您已经为提交按钮添加了name属性,请在php文件中更新您的代码以执行对此的SQL查询:

    $sql = "INSERT INTO Bee_Rewarded VALUES('$Email_Address','$First_Name','$Last_Name','$Phone_Number','$Birthday') ";

    $insert_data = mysql_query($conn,$sql);

if($insert_data)
{
    echo 'Data Added Successfuly';
}
else
{
    echo 'Error In Adding Data';
}