谁帮忙写个PHP代码,代码中有用户名和密码在页面输入正确就登陆到一个页面

大致就这个意思。谢谢了
2024-12-14 23:13:48
推荐回答(2个)
回答1:

session_start();
$coon_ = "localhost";
$name_ = "root";
$password_="root";
$error_ = "无法连接数据库1,请重来";
$conn=mysql_connect($coon_,$name_,$password_) or die($error_);
mysql_select_db("abc")
or die($error_);
mysql_query("SET NAMES 'gbk'");//解决汉字

$row = mysql_fetch_assoc(mysql_query(" SELECT pass,qx,sex FROM users where name = '$username' and pass = '$pass'"));
$dl_mima=$row[pass];$dl_qx=$row[qx];$dl_sex=$row[sex];
if($dl_mima=="")
{
echo "";
echo "







用户名:



密 码:






";
}
else
{

$_SESSION['yhm']=$username;
$_SESSION['qx']=$dl_qx;
$_SESSION['sex']=$dl_sex;
echo "";
echo "";
}

?>

回答2:

很多这种登陆的例子,百度一下就能找到这种表单提交的代码