php会员管理中注册新用户不能正确存储解决办法
Jun 13, 2016 pm 01:37 PM
php会员管理中注册新用户不能正确存储
1、处理代码如下:
include("dbconnect.inc.php");
include("functions.inc.php");
#如果php配置中,magic_quotes_gpc没有被设置,则执行过滤字符串。
$form = check_form($_POST["edit"]);
$form["reg_time"] = date("Y-m-d H:i:s");
$form["pass"] = md5($form["pass"]);
extract($form);
$sql = "insert into users( username,password,sex,mail,tel,web,birthday,inter,intro,reg_time) ";
#这里{}符号是代表在字符串中引用当前环境的变量
$sql .= " values('{$name}',";
$sql .= " '{$pass}',";
$sql .= " '{$sex}',";
$sql .= " '{$mail}', ";
$sql .= " '{$tel}', ";
$sql .= " '{$web}', ";
$sql .= " '{$birthday}', ";
$sql .= " '{$inter}', ";
$sql .= " '{$intro}', ";
$sql .= " '{$reg_time}') ";
$res = mysql_query($sql);
if(!$res) {
die("数据库出错,请返回重试。");
}
header("Location:msg.php?m=register_success");
?>
主要是出问题在第五行
$form = check_form($_POST["edit"]);
我试了,程序运行到这一行就会出错,但又不报错,如果在这一行前加‘#’,则提示存储成功,但只有6、7行的两个字段,请各位大虾不吝赐教,以下为以上包含使用的代码。
2、dbconnect.inc.php代码
include("settings.inc.php");
#connect to db
$con = mysql_connect($dbhost,$dbuser,$dbpass);
if(!$con) die("mysql error:".mysql_error());
mysql_select_db($dbname,$con);
?>
3、functions.inc.php代码
function check_form($form) {
if(!get_magic_quotes_gpc()) {
for($i=0;$i
}
}
return $form;
}
?>
4、settings.inc.php代码
#mysql服务器IP及数据库名
$dbhost = "localhost";
$dbname = "book";
$dbuser = "admin";
$dbpass = "123456";
?>
------解决方案--------------------
函数check_form改为
- PHP code
1 2 3 4 5 6 7 8 9 |
|
- PHP code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
|

熱門文章

熱門文章

熱門文章標籤

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

適用於 Ubuntu 和 Debian 的 PHP 8.4 安裝和升級指南

如何設定 Visual Studio Code (VS Code) 進行 PHP 開發
