4,250
社区成员
发帖
与我相关
我的任务
分享<?php
session_start();
if(!isset($_cookie['username'])){
setcookie("username",$username,time()+3600*24*2);
}
include("lianjie.php");
//$_SESSION['FORMINDEX'] = "yes";
?>
<!--***************登录页面***************-->
<link href="CSS/css.css" rel="stylesheet" type="text/css">
<body >
<table align="center">
<tr><td>
<table width="800px"align="center" style="background-image:url(img/tu_beijing.jpg);height:510px; " >
<tr ><td height="55" colspan="4"><img src="img/logo01.jpg" align="right">
</td>
</tr>
<tr>
<td height="240" colspan="3"></td>
<td width="430" valign="bottom"><form name="form1" method="post" action="" onsubmit="return Checkform();" style=" text-align:center; ">
<table border="0" cellspacing="0" cellpadding="1" align="left">
<tr>
<th colspan="2" align="center" height="50px"><font color="#000000" face="华文宋体" size="+1">用户登录</font></th>
</tr>
<tr>
<td height="30">
<div align="right" style="color:#000000; font-size:13px; height:10px;">用户名:</div></td>
<td align="left">
<input type="text" name="user_login" size="20" maxlength="16" style="border-color:#666666;">
</td>
</tr>
<tr><td height="30">
<div align="right" style="color:#000000;font-size:13px;height:30px;">密 码:</div></td>
<td align="left">
<input type="password" name="user_pass" size="20" maxlength="16" style="border-color:#666666;"><p>
</td>
</tr>
<tr>
<td colspan="2">
<div align="center">
<input type="image" name="login" value="" src="img/denglu.gif">
</div></td>
</tr>
</table>
</form>
</tr>
<tr>
<td colspan="3" height="190"> </td>
<td width="420">
</td></tr>
</table>
</td>
</tr>
<tr><td</td></tr>
</body>
<?php
$user_login=$_POST["user_login"];//赋值
$user_pass=$_POST["user_pass"];
if($user_login && $user_pass)
{
$query="select * from denglu where user='".$user_login."' and pwd='".$user_pass."'";//从数据库查找用户名和密码
$res=mysql_query($query,$connection);
if(mysql_fetch_array($res))
{
$_SESSION['user_login']=$user_login;//传递用户名
echo $SESSION['user_login'];
echo "<script>window.location='index_bc.php';</script>";exit();//登录成功跳转到index_bc
}else{
echo "<script>alert('用户名或密码错误');window.location='index.php';</script>";exit();}
}
mysql_close($connection);
?><?php
session_start();
/*if(!isset($_SESSION['FORMINDEX'])){
header("location: index.php");
}*/
$_SESSION['username']=$username;
if(!empty($_COOKIE['username']))
{
header("location: index.php");
}
else
{
header("location: index_bc.php");
}
?><?php
session_start();
include("lianjie.php");
?>
<!--***************登录页面***************-->
<link href="CSS/css.css" rel="stylesheet" type="text/css">
<body >
<table align="center">
<tr><td>
<table width="800px"align="center" style="background-image:url(img/tu_beijing.jpg);height:510px; " >
<tr ><td height="55" colspan="4"><img src="img/logo01.jpg" align="right">
</td>
</tr>
<tr>
<td height="240" colspan="3"></td>
<td width="430" valign="bottom"><form name="form1" method="post" action="" onSubmit="return Checkform();" style=" text-align:center; ">
<table border="0" cellspacing="0" cellpadding="1" align="left">
<tr>
<th colspan="2" align="center" height="50px"><font color="#000000" face="华文宋体" size="+1">用户登录</font></th>
</tr>
<tr>
<td height="30">
<div align="right" style="color:#000000; font-size:13px; height:10px;">用户名:</div></td>
<td align="left">
<input type="text" name="user_login" size="20" maxlength="16" style="border-color:#666666;">
</td>
</tr>
<tr><td height="30">
<div align="right" style="color:#000000;font-size:13px;height:30px;">密 码:</div></td>
<td align="left">
<input type="password" name="user_pass" size="20" maxlength="16" style="border-color:#666666;"><p>
</td>
</tr>
<tr>
<td colspan="2">
<div align="center">
<input type="image" name="login" value="" src="img/denglu.gif">
</div></td>
</tr>
</table>
</form>
</tr>
<tr>
<td colspan="3" height="190"> </td>
<td width="420">
</td></tr>
</table>
</td>
</tr>
<tr><td</td></tr>
</body>
<?php
$user_login=$_POST["user_login"];//赋值
$user_pass=$_POST["user_pass"];
if($user_login && $user_pass)
{
$query="select * from denglu where user='".$user_login."' and pwd='".$user_pass."'";//从数据库查找用户名和密码
$res=mysql_query($query,$connection);
if(mysql_fetch_array($res))
{
$_SESSION['user_login']=$user_login;//传递用户名
$_SESSION['FORMINDEX'] = "yes";
echo "<script>window.location='index_bc.php';</script>";exit();//登录成功跳转到index_bc
}else{
echo "<script>alert('用户名或密码错误');window.location='index.php';</script>";exit();}
}
mysql_close($connection);
?>
<?php
session_start();
/*if(!isset($_SESSION['FORMINDEX'])){
header("location: index.php");
}*/
if($_SESSION['FORMINDEX'] = "yes")
{
header("location: index_bc.php");
}
else
{
header("location: index_.php");
}
?>