PHP编程如何写一个登陆系统?
<?phpsession_start();
include_once '../connect.php'; //执行连接数据库的操作
$name = addslashes($_POST['name']); //获取用户名
$pwd = $_POST['pwd']; //获取密码
if(!empty($name) and !empty($pwd)){
$sql = "select * from admin where name = '".$name."' and password = '".$pwd."'";
$num = $conne->getRowsNum($sql); //返回查询结果
if($num == 0 or $num == ''){ //如果不正确
echo "<script>alert('用户名和密码不正确!'); window.location.href='index.php';</script>";
}else{ //如果正确,则将登录用户名数据存储到Cookie中
$_SESSION[name]=$name;
echo "<script>alert('登录成功!'); window.location.href='default.php';</script>";
}
}
?>
我的这个语句为什么第7行老实出错,哪位大侠帮我理解下