PHP和SQL(尝试使用提交按钮更新我的数据库)

时间:2016-06-08 10:43:39

标签: php html mysql

我正在尝试使用提交按钮更新我的SQL数据库表单中的反馈,但我无法这样做。请帮忙!

if (isset($_POST['submitreport'])) 
            {
                $dbCon = mysqli_connect("localhost","root","","Hun");
                $report = strip_tags($_POST['report']);

                $sql = "UPDATE Feedback SET report='$report' WHERE username='$username' AND date='$date' ";

                $query = mysqli_query($dbCon, $sql);


            }

2 个答案:

答案 0 :(得分:3)

<?php
      if (isset($_POST['submitreport'])) 

    {
       $monthDayYear = date('m-d-Y');

       $dbConnnection = mysqli_connect("localhost","root","","Hun");

       $dbUsername = strip_tags($_POST['report']);

       $sqlQuery = "UPDATE Feedback SET report='".$report."' WHERE username='".$username."' AND date='".$monthDayYear."'";

       $queryExecute = mysqli_query($dbConnection, $sqlQuery);


       }

    ?>

答案 1 :(得分:0)

    <?php
    if (isset($_POST['submitreport'])) 
    {
    $dbCon = mysqli_connect("localhost","root","","Hun");
    $username = 'test';
    $report = strip_tags($_POST['report']);
    $date = date('m-d-Y');

    $sql = "UPDATE Feedback SET report='".$report."' WHERE username='".$username."' AND date='".$date."'";

    $query = mysqli_query($dbCon, $sql);
    }
    ?>