脚本宝典收集整理的这篇文章主要介绍了Php在提交表单之前将数据插入到具有空值的数据库中?,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_301_7@
@H_404_11@<htML> <body> <form action="insert.PHP" method="post"> Firstname: <input tyPE="text" name="firstname"> Lastname: <input type="text" name="lastname"> Age: <input type="text" name="age"> <input type="submIT"> </form> </body> </html> <?PHP $con=MysqLi_connect("example.COM","peter","abc123","my_db"); // Check connection if (MysqLi_connect_errno()) { echo "Failed to connect to MysqL: " . MysqLi_connect_error(); } $sql="INSERT INTO Persons (FirstName,LastName,Age) VALUES ('$_POST[firstname]','$_POST[lastname]','$_POST[age]')"; if (!MysqLi_query($con,$sql)) { die('Error: ' . MysqLi_error($con)); } echo "1 record added"; MysqLi_close($con); ?> @H_419_4@@H_301_7@你还需要在input type =“submit”html元素中添加一些值和名称
@H_301_7@@H_404_11@<input type="submit" name="submit" value="Submit!" /> @H_419_4@ @H_419_4@
以上是脚本宝典为你收集整理的Php在提交表单之前将数据插入到具有空值的数据库中?全部内容,希望文章能够帮你解决Php在提交表单之前将数据插入到具有空值的数据库中?所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。