21,893
社区成员




<?php
error_reporting(0);
@session_start();
require_once 'conn/conn.php';
$user_name=$_POST['name'];
$password=md5($_POST['password']);
$_SESSION['user_name']=$user_name;
if(strlen($user_name)<1){
?>
<html>
<head>
<title>管理员登陆</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<center>
<form method="post" action="admin.php">
<table border='1'>
<tr>
<th colspan='2' bgcolor='cccccc'>用户登陆</th>
</tr>
<tr>
<td align='right'>Username:</td>
<td><input type='text' name='name' maxlength='16' size='16'></input></td>
</tr>
<tr>
<td align='right'>Password:</td>
<td><input type='password' name='password' size='16' maxlength='10'></input></td>
</tr>
<tr>
<td colspan='2'><font size="2"><input type='submit' value='确认登陆'></input>
<input type='reset' value='重新填写'></input>
<a href='message.php'>注册新用户</a>
</font></td>
</tr>
</table>
</form>
</center>
<?php
}
else if(strlen($user_name)>1){
$query="select * from admin where user_name=? and password=?";
// echo $query;
// exit;
$st=$db->prepare($query);
$rs = $st->execute(array($user_name,$password));
if($rs == false)
{
echo "<center><script>alert('登陆失败!');window.location.href='admin.php'</script></center>";
}
else
{
// echo "登陆成功!";
echo "<center><script>alert('管理员登陆成功!');window.location.href='admin_select_neirong.php'</script></center>";
}
}
?>
</body>
</html>