0

I've got this form, where the values should insert into the database. There are no errors when it runs, but does not update the database. Under here i posted the html of the page.

<!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>

AND IT BRINGS UP THIS PAGE

<?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";


?>
CFleming
  • 19
  • 6
  • 3
    **Danger**: You are using [an **obsolete** database API](http://stackoverflow.com/q/12859942/19068) and should use a [modern replacement](http://php.net/manual/en/mysqlinfo.api.choosing.php). You are also **vulnerable to [SQL injection attacks](http://bobby-tables.com/)** that a modern API would make it easier to [defend](http://stackoverflow.com/questions/60174/best-way-to-prevent-sql-injection-in-php) yourself from. – Quentin Feb 28 '14 at 16:19

1 Answers1

0

Case 1: Your request actually goes where it should and script is run: Your problem seems to be the query (except the obsolete extension and sql injection):

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

Note the back ticks of DateExpiry and the way variables are included in string.

Case 2: The opposite of case 1... anything may happen.

zozo
  • 7,359
  • 17
  • 66
  • 118