我知道这不是将数据插入 mysql 的安全方法,但这只是示例!请这个脚本没有将任何数据添加到具有这些字段的 mysql 表中:
<?php
session_start();
if(!isset($_SESSION['c_id']) || !isset($_SESSION['sid']) ||!isset($_SESSION['ip'])) {
header("Location: login.php");
exit;
}
?>
<?php
$cid1= $_POST['hiddencid'];
$update= $_POST['hiddenupdate'];
$time = strftime("%b %d %Y %X");
mysql_connect('localhost', 'xxx', 'xxx') or die(mysql_error());
mysql_select_db("xxx") or die(mysql_error());
mysql_query("INSERT into newsfeed (cid,update,time) values ('$cid1','$update','$time')");
echo "Profile Updated";
?>
最佳答案
您的列名称更新是保留字,需要特殊处理。在启用 ANSI SQL 模式的情况下使用双引号或反引号。
http://dev.mysql.com/doc/refman/5.1/en/reserved-words.html .
INSERT into newsfeed (cid,`update`,time) values ('$cid1','$update','$time');
关于php - 表单数据不会添加并且 MySql 表保持为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6761673/