PHP初学者的问题,求助!

来源:百度知道 编辑:UC知道 时间:2024/05/30 01:40:29
add.html 的代码
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=gbk">
<title>会员注册</title>
</head>
<body>
<h1>会员注册</h1>
<form name="form1" action=add_chk.php method=post>
<p>账号:<input type="text" name="id"></p>
<p>密码:<input type="password" name="passwd"></p>
<p><input type="submit" name="提交"><input type="reset" name="重置"></p>
</form>
</body>
</html>
add_chk.php的代码
<?
include_once("sql_connect.php");
include_once("msg.php");

if($_POST['id']==''or $_POST['passwd']=''){my_msg("字段不可空白","add.html");}
$sqlstr="insert into member values('

if (!$_POST['id'] || !$_POST['passwd'])
{
my_msg("字段不可空白","add.html");
}

$sqlstr = "insert into member (id,passwd) values ('".$_POST['id']."','".$_POST['passwd']."')";

if (mysql_query($sqlstr, $link))
{
my_msg("添加用户成功","index.php");
}

mysql_close($link);

$_POST['id']==''or $_POST['passwd']=''
掉了一个 =

是不是 add_chk.php 的sql语句构造错了?你用echo输出下看看,直接在数据库执行下看对不对。

还有可能是你调用 my_msg("字段不可空白","add.html");第二个参数的路径问题。这几个文件是不是在同级目录下。

啥教材啊..肯定中国人写的...

这样的代码编写方式..悲惨!~~~