求写个比较简单的php登陆页面代码

2024-12-21 21:32:58
推荐回答(2个)
回答1:

index.php 录入页代码















用户名:

密 码:




login.php提交页代码error_reporting(0);
$mysql_servername = "127.0.0.1";
$mysql_username = "root";
$mysql_password ="123456";
$mysql_database ="first";
mysql_connect($mysql_servername , $mysql_username , $mysql_password);
mysql_select_db($mysql_database);

$U_name=$_POST['user_name'];
$U_passowrd=$_POST['user_password'];

if ($U_name && $U_passowrd){
$sql = "SELECT * FROM admin WHERE U_name = '$U_name' and U_password='$U_passowrd'";
$res = mysql_query($sql);
$rows=mysql_num_rows($res);
if($rows){
header("location='c.php'");
exit;
}
echo "";
}else {
echo "";
}

?>

回答2:

主页面:index.php


账号:

密码:

输入验证码:
< br />

判断页面:login.php//再连库判断账号密码
require_once("../inc/dbconfig.php");
$adminAccount=$_POST['adminAccount'];
$adminPass=md5($_POST['adminPass']);
$sql="select * from admin where adminAccount='$adminAccount' and adminPass='$adminPass'";
$result=mysql_query($sql) or die($sql);
$rows=mysql_num_rows($result);
if($rows==0){
?>

exit();
}
//将管理员账号赋值给session
$_SESSION['adminAccount']=$adminAccount;
?>
配置文件自己来就行了!