六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 41|回复: 0

php登录代码

[复制链接]

升级  17.33%

22

主题

22

主题

22

主题

秀才

Rank: 2

积分
76
 楼主| 发表于 2013-1-28 09:07:27 | 显示全部楼层 |阅读模式
 
供大家参考
<?php         error_reporting(0);         header("content_type:text/html;charset=gbk");         $conn=mysql_connect("localhost","root","") or die("链接错误");         mysql_select_db("phptest",$conn);//     echo "链接成功"."<br>";         $username=$_POST['username'];         $password=$_POST['password'];//     echo "用户输入的是:"."$username"."<br>"."$password";         $sqla="select * from user";         $sqlb="select * from user where username='$username'";         $sqlc="select * from user where username='$username' and password='$password'";         $resulta=mysql_query($sqla,$conn);         $resultb=mysql_query($sqlb,$conn);         $resultc=mysql_query($sqlc,$conn);         $numa=mysql_num_rows($resulta);         $numb=mysql_num_rows($resultb);         $numac=mysql_num_rows($resultc);         if($username=="" or $password==""){                   echo "用户名或密码不能为空";         }else if($numb>0 ){                   while($all=mysql_num_rows($result)){                            echo "$all[username]"."   "."$all[password]"."<br>";                   }                            }         ?><html>         <body>                   <form action="newTest.php" method="post">                            <ul>                            <li>username:<input type="text" name="username"/></li>                            <li>password:<input type="text" name="password"/></li>                            <li><input type="submit" name="sub"value="sub"/></li>                   </ul>                   </form>         </body></html> 

 
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表