Php 数据库SQL中未更新HTML表单
我有一个表单,其中的值应该插入到数据库中。运行时没有错误,但不会更新数据库。在这里,我发布了页面的htmlPhp 数据库SQL中未更新HTML表单,php,html,sql,ajax,insert,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
<!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; >
<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; >
<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; >
<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; >
<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:您的请求实际到达了它应该到达的地方,并且脚本正在运行: 您的问题似乎是除了过时的扩展和sql注入之外的查询:
$sql="
INSERT INTO `LandingPage_Notifications`(`ID`, `HTML`, `DateExpiry`)
VALUES ('{$_POST['Title']}', '{$_POST['htmlBox']}', '{$_POST['Expiry']}')
";
$result = mysql_query($sql);
请注意DateExpiry的背面标记以及变量在字符串中的包含方式
案例2:与案例1相反。。。任何事情都有可能发生。危险:您正在使用,并且应该使用。你也很容易受到这个问题的影响,现代的API会让你更容易从中受益。我不确定我是否明白你的意思。如果查询仍然不起作用,请使用var\u dump$\u POST并告诉我们答案。您有很多问题。您应该更新该问题,以便其他人可以使用结果作为帮助