php 访问mysql数据库验证登录

php 访问mysql数据库验证登录

静态网页代码



欢迎登录

欢迎登录



用户名:

  密码:

 






服务器 checkLogin.php 代码

      //用户登录验证
$us = $_GET["uName"];
$up = $_GET["uPassword"];

//连接数据库
//1、创建连接 "127.0.0.1"为数据库地址,此例中为本机地址,"root"为数据库用户名,"123456"为数据库密码
$conn = mysql_connect("127.0.0.1","root","123456");
//2、打开数据库  "newsDB"为数据库名
mysql_select_db("newsDB");
//3、sql语句
$sql = "select * from user where userName='".$us."' and password='".$up."';";
//4、执sql语句
$result =   mysql_query($sql); 
$num = mysql_num_rows($result);
//5、关闭数据库

mysql_close($conn);

//如果返回的不为空,则登录成功

if($num >0)
{
echo "login ok!!!";
}
else
{
echo "login faile! please try again!";
}
?>

你可能感兴趣的:(ios开发技术)