如何将<input />值发布到数据库

时间:2016-07-07 05:22:51

标签: php html sql

单击“提交”按钮时,我的<input>值不会发布到我的数据库中。我无法找到错误。请帮忙。

 <?php
    echo "<form action=Display.php method=post>";
    echo "<td>" . $fiberexcel['Engineer9'] ." </td>";
    echo "<td>" . $fiberexcel['AM10'] ." </td>";
    echo "<td>" . "<input type=date name=A12 value=" . $fiberexcel['Quotation11'] ." </td>";

    $A6 = date("Y-m-d");
    $ExpectDateQuotation12 = strtotime($ReqDate4."+ 10 weekday");
    echo "<td>" . date("Y-m-d",$ExpectDateQuotation12) . "</td>";
    $ExpectDateQuotation12 = date("Y-m-d",$ExpectDateQuotation12);
    $UpdateQuery = "UPDATE `fiberexcel` SET `ExpectDateQuotation12` =
    '$ExpectDateQuotation12' WHERE `fiberexcel`.`SiteID0` = '$A1';";
    mysqli_query($conn, $UpdateQuery);

    echo "<td>" . "<input type=date name=A14 value=" . $fiberexcel['ApprovalJFSRequest13'] ." </td>";
    ?>

    echo "<td>" . "<input type=hidden name=hidden value=" .$fiberexcel['SiteID0'] ." </td>";
    //echo "</tr>";
    echo "<td>" . "<input type=submit name=update value=update>". "</td>";
    echo "</form>";

这是我的更新按钮帖子功能:

    if(isset($_POST['update'])){
       $UpdateQuery = "UPDATE `fiber`.`fiberexcel` SET Quotation11='$_POST[A12]' ,  ApprovalJFSRequest13='$_POST[A14]' WHERE `fiberexcel`.`SiteID0`='$_POST[hidden]'";

       mysqli_query($conn, $UpdateQuery);
    };

2 个答案:

答案 0 :(得分:0)

请您在浏览器中查看HTML输出。

我注意到您的代码中存在一些问题

- 您错过了每个属性值的引号     例如:     echo&#34;&#34;;

wolud就像     echo&#34;&#34;;

  • 您的HTML代码中也有错误, 例如: 回声&#34;&#34; 。 &#34;&#34 ;; 这里你错过了关闭输入标签,

你的代码如下所示,

<?php
echo "<form action='Display.php' method='post'>";

echo "<td>" . $fiberexcel['Engineer9'] ." </td>";
echo "<td>" . $fiberexcel['AM10'] ." </td>";
echo "<td>" . "<input type='date' name='A12' value='" . $fiberexcel['Quotation11'] ."'></td>";

$A6 = date("Y-m-d");
$ExpectDateQuotation12 = strtotime($ReqDate4."+ 10 weekday");
echo "<td>" . date("Y-m-d",$ExpectDateQuotation12) . "</td>";
$ExpectDateQuotation12 = date("Y-m-d",$ExpectDateQuotation12);
$UpdateQuery = "UPDATE `fiberexcel` SET `ExpectDateQuotation12` =
'$ExpectDateQuotation12' WHERE `fiberexcel`.`SiteID0` = '$A1';";
mysqli_query($conn, $UpdateQuery);

echo "<td>" . "<input type='date' name='A14' value='" . $fiberexcel['ApprovalJFSRequest13'] ."'> </td>";
echo "<td>" . "<input type='hidden' name='hidden' value='" .$fiberexcel['SiteID0'] ."'> </td>";
//echo "</tr>";
echo "<td>" . "<input type='submit' name='update' value='update'>". "</td>";
echo "</form>";
?>

答案 1 :(得分:0)

您的代码中存在一些语法错误。请检查php close标签并输入close标签。试试这个..

<?php
echo "<form action='Display.php' method='post'>";
echo "<td>" . $fiberexcel['Engineer9'] ." </td>";
echo "<td>" . $fiberexcel['AM10'] ." </td>";
echo "<td><input type='date' name='A12' value=" . $fiberexcel['Quotation11'] ."/></td>";

$A6 = date("Y-m-d");
$ExpectDateQuotation12 = strtotime($ReqDate4."+ 10 weekday");
echo "<td>" . date("Y-m-d",$ExpectDateQuotation12) . "</td>";
$ExpectDateQuotation12 = date("Y-m-d",$ExpectDateQuotation12);
$UpdateQuery = "UPDATE `fiberexcel` SET `ExpectDateQuotation12` =
'$ExpectDateQuotation12' WHERE `fiberexcel`.`SiteID0` = '$A1';";
mysqli_query($conn, $UpdateQuery);

echo "<td><input type='date' name='A14' value=" . $fiberexcel['ApprovalJFSRequest13'] ." /></td>";


echo "<td><input type='hidden' name='hidden' value=" .$fiberexcel['SiteID0'] ." /></td>";
//echo "</tr>";
echo "<td><input type='submit' name='update' value='update'></td>";
echo "</form>";

?>