HTML表单未在数据库SQL中更新

时间:2014-02-28 16:15:15

标签: php html sql ajax insert

我有这个表单,值应该插入到数据库中。运行时没有错误,但不更新数据库。在这里,我发布了页面的HTML。

<!DOCTYPE html>
<html>
<title>css</title>
<body style="overflow-y: hidden; background-color: #011D50 ">
<div id="header" style=" padding-top: 0px; padding-left:0px; padding-right:0px; padding-        bottom: 0px; ;">

<div align="left"><img src="../images/topbar.jpg" alt="topbar" width=100%;/>
</div>
<head>
<link type= "text/css" rel="stylesheet" href= "Doc2css.css" />
</head>

<div style=" position:absolute; align: center; left: 27%; height: 100%; width: 50%;    background-color: lightblue; overflow:show; opacity: 0.9;">
<form class ="form" action="insertNotifications.php" method="POST">
    <div class="fieldset" " style="padding-top: 5%;">
      <li style="list-style-type: none;">
        <ul style=" padding-top: 5%; list-style-type: none; text-align: left;">
              <li style="display: inline; &gt;
                    &lt;label class=; border-radius: 0px;   margin-top: -17px; margin-right: -17px; margin-bottom: -17px; margin-left:   -5px;"label">TITLE:</label>
                 <span style="display: inline-block; left: 138px; right:   185px; padding-left: 86px;">
                 <input class="input" type="text" name="Title" value=""   style="height: 30px; width: 100%; font-size: 20px; position: static;">
              </span></li>

        </ul>
        <ul style=" padding-top: 5%; list-style-type: none; text-align:    left;">
              <li style="display: inline; &gt;
                    &lt;label class=; border-radius: 0px;   margin-top: -17px; margin-right: -17px; margin-bottom: -17px; margin-left:   3px;"label">CONTENT:</label>
                <span style="display: inline-block; left: 138px; right: 185px; padding-left: 42px; min-width: 0px; /* [disabled]height: 133px; */">
                <input class="input" type="text" name="htmlBox" value=""    style=" height: 80px; width: 180%; font-size: 20px;">
              </span></li>

        </ul>
        <ul style="  padding-top: 5%; list-style-type: none; text-align:   left;">
              <li style="display: inline; &gt;
                    &lt;label class=; border-radius: 0px;   margin-top: -17px; margin-right: -17px; margin-bottom: -17px; margin-left: -3px;"label">   DATE EXPIRY:</label>
                <span style="display: inline-block; left: 138px; right:   185px; padding-left: 29px;">
                <input class="input" type="date" name="Expiry" value=""    style="height: 30px; width: 140%px; font-size: 20px;">
              </span></li>

        </ul>
        <ul style="  padding-top: 5%; list-style-type: none; text-align:   left;">
  <li style="display: inline; &gt;
                    &lt;label class=; border-radius: 0px;   margin-top: -17px; margin-right: -17px; margin-bottom: -17px; margin-left: 37%;"label">                          </label>
                <span style="display: inline-block; left: 138px; right: 185px; padding-left: 29px;">
                <input class="input" type="submit" value="Submit" value="" style="height: 30px; width: 140%px; font-size: 20px;">
              </span></li>

        </ul>
        </li>
        </li>

  </div>

</form></div>
</body>
</html>

它带来了这个页面

<?php


 %CONNECTION CODE GOES HERE; THATS NOT THE PROBLEM%


    $sql="INSERT INTO `LandingPage_Notifications`(`ID`, `HTML`,'DateExpiry') VALUES           ('$_POST[Title]', '$_POST[htmlBox]', '$_POST[Expiry]')";
        $result = mysql_query($sql);

echo "Notification Created";


?>

1 个答案:

答案 0 :(得分:0)

案例1:您的请求实际上应该在应该运行的位置并运行脚本: 您的问题似乎是查询(除了过时的扩展和SQL注入):

    $sql="
       INSERT INTO `LandingPage_Notifications`(`ID`, `HTML`, `DateExpiry`) 
       VALUES ('{$_POST['Title']}', '{$_POST['htmlBox']}', '{$_POST['Expiry']}')
    ";
    $result = mysql_query($sql);

请注意DateExpiry的后退标记以及变量包含在字符串中的方式。

案例2:与案例1相反......任何事情都可能发生。