首页 > 数据库 > mysql教程 > php-PHP中mysql_num_rows问题

php-PHP中mysql_num_rows问题

WBOY
发布: 2016-06-06 09:35:05
原创
1153 人浏览过

mysqlphp数据库

图片说明

<code> <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>注册</title>
<?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);";        }        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);</code>
登录后复制

图片说明

<code> <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>登陆</title>
<?php if(isset($_POST["submit"]) && $_POST["submit"] == "登陆")    {        $user = $_POST["username"];        $psw = $_POST["password"];        if($user == "" || $psw == "")        {            echo "<script>alert('请输入用户名或密码!'); history.go(-1);";        }        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);</code>
登录后复制
相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板