PHP中mysql_num_rows问题

图片说明

 <head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>注册</title>
</head>
<?php
    if(isset($_POST["Submit"]) && $_POST["Submit"] == "注册")
    {
        $user = $_POST["username"];
        $psw = $_POST["password"];
        $psw_confirm = $_POST["confirm"];
        if($user == "" || $psw == "" || $psw_confirm == "")
        {
            echo "<script>alert('请确认信息完整性!'); history.go(-1);</script>";
        }
        else
        {
            if($psw == $psw_confirm)
            {
                mysql_connect("localhost","root","");   //连接数据库
                mysql_select_db("用户表");   //选择数据库
                mysql_query("set names 'gdk'"); //设定字符集
                $sql = "select username from user where username = '$_POST[username]'"; //SQL语句
                $result = mysql_query($sql);    //执行SQL语句
                $num = mysql_num_rows($result);

图片说明

 <head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>登陆</title>
</head>
<?php
    if(isset($_POST["submit"]) && $_POST["submit"] == "登陆")
    {
        $user = $_POST["username"];
        $psw = $_POST["password"];
        if($user == "" || $psw == "")
        {
            echo "<script>alert('请输入用户名或密码!'); history.go(-1);</script>";
        }
        else
        {
            mysql_connect("localhost","root","");
            mysql_select_db("用户表");
            mysql_query("set names 'gbk'");
            $sql = "select username,password from user where username = '$_POST[username]' and password = '$_POST[password]'";
            $result = mysql_query($sql);
            $num = mysql_num_rows($result);
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问