4,250
社区成员
发帖
与我相关
我的任务
分享<?php
if ($login){
$db_host="127.0.0.1:3306";
$db_user="root";
$db_psw="";
$db_name="hotel";
$connection=mysql_connect($db_host,$db_user,$db_psw)or die("选择服务器失败");
mysql_select_db($db_name,$connection)or die("选择数据库失败");
session_start();
$right_enter='0';
$query="select * from Background where user='$user_login' and pwd='$user_pass'";
$result=@mysql_query($query,$connection);
if ($user_array=@mysql_fetch_array($result)){
$user_id=$user_array[user_id];
$user_name=$user_array[user_info];
session_register("user_id");
session_register("user_name");
session_register("user_array");
if(($user_array[ticket_day]) and ($user_array[ticket_num])){
$right_enter='1';
echo "<script>alert('登录成功');window.location='index_bc.php';</script>";
}
else{
$error_message="<script>alert('您没有登录权限');window.location='Untitled-3.php';</script>";
}
}
else{
$error_message="<script>alert('用户名或密码错误,请重新登录.');window.location='Untitled-3.php';</script>";
}
}
if($logout){
session_start();
session_unregister("user_id");
session_unregister("user_name");
session_unregister("user_array");
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<p> </p>
<form name="form1" method="post" action="" >
<table width="289" border="1" cellspacing="0" cellpadding="1" bordercolor="#999999" align="center">
<tr bgcolor="#999999">
<td>
<div align="center"><font color="#FFFFFF" size="4">用户登录</font></div>
</td>
</tr>
<tr>
<td>
<table width="267" border="0" cellspacing="0" cellpadding="5" align="center">
<tr>
<td width="94">
<div align="right">用户:</div>
</td>
<td width="169">
<input type="text" name="user_login" size="16" maxlength="16" value="<?php echo $user_login; ?>">
</td>
</tr>
<tr>
<td width="94">
<div align="right">口令:</div>
</td>
<td width="169">
<input type="password" name="user_pass" size="16" maxlength="16">
</td>
</tr>
<tr>
<td colspan="2">
<div align="center">
<input type="submit" name="login" value=" 登 录 ">
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>$user_login=$_POST["user_login"];
$user_pass=$_POST["user_pass"];
$query="select * from Background where user='".$user_login."' and pwd='".$user_pass."'";
if($res=mysql_query($query,$connection))
{
$_SESSION['user_login']=$user_login;
$_SESSION['user_pass']=$user_pass;
header('location:index_bc.php'); //就是这行
}
else
{
echo "<script>alert('用户名或密码不正确');</script>";
}$user_login=$_POST["user_login"];
$user_pass=$_POST["user_pass"];
$query="select * from Background where user='".$user_login."' and pwd='".$user_pass."'";
if($res=mysql_query($query,$connection))
{
$_SESSION['user_login']=$user_login;
$_SESSION['user_pass']=$user_pass;
header('location:index_bc.php');
}
else
{
echo "<script>alert('用户名或密码不正确');</script>";
}
<?php
session_save_path(dirname(__FILE__).'/');
session_start();
foreach($_POST as $_key=>$_value){
!ereg("^\_",$_key) && !isset($$_key) && $$_key=$_POST[$_key];
}
foreach($_GET as $_key=>$_value){
!ereg("^\_",$_key) && !isset($$_key) && $$_key=$_GET[$_key];
}
if ($action=="login"){
$db_host="127.0.0.1:3306";
$db_user="root";
$db_psw="";
$db_name="hotel";
$connection=mysql_connect($db_host,$db_user,$db_psw)or die("选择服务器失败");
mysql_select_db($db_name,$connection)or die("选择数据库失败");
$right_enter='0';
$query="select * from Background where user='$user_login' and pwd='$user_pass'";
$result=@mysql_query($query,$connection);
if ($user_array=@mysql_fetch_array($result)){
$user_id=$user_array['user_id'];
$user_name=$user_array['user_info'];
$_SESSION["user_id"]=$user_id;
$_SESSION["user_name"]=$user_name;
$_SESSION["user_array"]=$user_array;
if($user_array['ticket_day'] && $user_array['ticket_num']){
$error_message="<script>alert('登录成功');window.location='index_bc.php';</script>";
}else{
$error_message="<script>alert('您没有登录权限');window.location='Untitled-3.php';</script>";
}
}else{
$error_message="<script>alert('用户名或密码错误,请重新登录.');window.location='Untitled-3.php';</script>";
}
echo $error_message;exit;
}elseif($action=="logout"){
isset($_SESSION["user_id"]) && unset($_SESSION["user_id"]);
isset($_SESSION["user_name"]) && unset($_SESSION["user_name"]);
isset($_SESSION["user_array"]) && unset($_SESSION["user_array"]);
}else{
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<p> </p>
<form name="form1" method="post" action="" >
<table width="289" border="1" cellspacing="0" cellpadding="1" bordercolor="#999999" align="center">
<tr bgcolor="#999999">
<td>
<div align="center"><font color="#FFFFFF" size="4">用户登录</font></div>
</td>
</tr>
<tr>
<td>
<table width="267" border="0" cellspacing="0" cellpadding="5" align="center">
<tr>
<td width="94">
<div align="right">用户:</div>
</td>
<td width="169">
<input type="text" name="user_login" size="16" maxlength="16" value="<?php echo $user_login; ?>">
</td>
</tr>
<tr>
<td width="94">
<div align="right">口令:</div>
</td>
<td width="169">
<input type="password" name="user_pass" size="16" maxlength="16">
</td>
</tr>
<tr>
<td colspan="2">
<div align="center">
<input type="hidden" name="action" value="login">
<input type="submit" name="submit" value=" 登 录 ">
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>
<?php
}
?>
<?php
session_start();
?>
<?php
include("lianjie.php");
foreach($_POST as $_key=>$_value){
!ereg("^\_",$_key) && !isset($$_key) && $$_key=$_POST[$_key];
}
foreach($_GET as $_key=>$_value){
!ereg("^\_",$_key) && !isset($$_key) && $$_key=$_GET[$_key];
}
if ($login){
$user_login=$_POST["user"];
$user_pass=$_POST["pwd"];
$right_enter='0';
$query="select * from Background where user='$user_login' and pwd='$user_pass'";
$result=@mysql_query($query,$connection);
echo "<script>alert('登录成功.');window.location='index_bc.php';</script>";
}
else{
echo "<script>alert('用户名或密码错误,请重新登录.');window.location='Untitled-3.php';</script>";
}
?>
foreach($_POST as $_key=>$_value){
!ereg("^\_",$_key) && !isset($$_key) && $$_key=$_POST[$_key];
}
foreach($_GET as $_key=>$_value){
!ereg("^\_",$_key) && !isset($$_key) && $$_key=$_GET[$_key];
}
$login = isset($_POST['login']) ? TRUE : FALSE;
if ($login){
$db_host="127.0.0.1:3306";
$db_user="root";
$db_psw="";
$db_name="hotel";
$connection=mysql_connect($db_host,$db_user,$db_psw)or die("选择服务器失败");
mysql_select_db($db_name,$connection)or die("选择数据库失败");
$user_login=$_POST["user"];
$user_pass=$_POST["pwd"];
session_start();
// $right_enter='0';
$query="select * from Background where user='$user_login' and pwd='$user_pass'";
$result=@mysql_query($query,$connection);
/*if ($user_array=@mysql_fetch_array($result)){
$user_id=$user_array[user_id];
$user_name=$user_array[user_info];
session_register("user_id");
session_register("user_name");
session_register("user_array");
if(($user_array[ticket_day]) and ($user_array[ticket_num])){
$right_enter='1';
echo "<script>alert('登录成功');window.location='index_bc.php';</script>";
}
else{
$error_message="<script>alert('您没有登录权限');window.location='Untitled-3.php';</script>";
}
}
else{
$error_message="<script>alert('用户名或密码错误,请重新登录.');window.location='Untitled-3.php';</script>";
}*/