PHP在登录系统中,不管输入任何登录子页网址,都必须先登陆主页 比如我的主页网址为inden,子页为inden_zy,我在浏览器中输入子页网址时,必须先跳转到主页的index网址该怎样写 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 if()//判断没有登录{ header("Location: index.php\n"); exit;} index中在SESSION中设定一个标志位$_SESSION['FORMINDEX'] = "yes";然后在index_zy中判断session_start();if(!isset($_SESSION['FORMINDEX'])){ header("location: index.php");} 写后报错Cannot send session cache limiter - headers already sent (output started at D:\APMServ5.2.6\www\htdocs\hotel_index\lianjie.php:8)什么意思 header之前不能有输出。echo,print_r,HTML页面输出都不可以有。 还是不行啊,这是主页代码<?phpsession_start();include("lianjie.php");?><?php$_SESSION['FORMINDEX'] = "yes";?><script type="text/javascript">function Checkform(){ if(document.form1.user_login.value==""){ alert("用户名不能为空"); document.form1.user_login.focus(); return false;}else if(document.form1.user_pass.value == ""){ alert("密码不能为空"); document.form1.user_pass.focus(); return false;}else{ return true;}}</script><!--***************登录页面***************--><link href="CSS/css.css" rel="stylesheet" type="text/css"><body ><table width="800px"align="center" ><tr><td align="right" valign="top"><img src="img/logo01.jpg" align="right"></td></tr><tr><td height="252" colspan="3"> <form name="form1" method="post" action="" onsubmit="return Checkform();" style=" text-align:center; "> <table width="100%" height="300" style="background-image:url(img/background.jpg);"> <tr> <td align="center" colspan="2"> <table border="0" cellspacing="0" cellpadding="1" align="center"> <tr> <td colspan="2" align="center" height="50px"><font color="#FFFFFF" face="华文宋体" size="+1">用户登录</font></td> </tr> <tr> <td height="30"> <div align="right" style="color:#FFFFFF; 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:#FFFFFF;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/hotel_dl.jpg"> </div></td> </tr> </table></td> </tr> </table> </form> </td></tr></table></body><?php$user_login=$_POST["user_login"];//赋值$user_pass=$_POST["user_pass"];if($user_login && $user_pass){ $query="select * from background 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.htm';</script>";exit();//登录成功跳转到index_bc }else{ echo "<script>alert('用户名或密码错误');window.location='index.php';</script>";exit();}}这是子页<?phpinclude("lianjie.php");?><link href="CSS/css.css" rel="stylesheet" type="text/css"><script> function delconfirm(){ if(window.confirm( "请确认是否删除? ")){ return true; } return false; } </script> <form method="POST" action=""><fieldset style="width:600px;"><legend>酒店活动数据查询</legend><p><table width="600"> <tr> <td align=left>搜 索 条 件 :<select name="ziduan" style="width:155px;"><option value="select=select">查看全部数据</option><option value="hotel_id">酒店ID</option><option value="content">内容介绍</option><option value="source">备注</option><option value="s_type">s_type</option> </td> <td align=left>搜索关键字:<input name="txt_sousuo" type="text" value=""/> </td> <td align="left"> <input name="sousuo" type="image" value="" src="img/03.gif" /> </td> </tr></table></fieldset></form><p><?php。。。?><?phpecho "</div>";echo "</table>";echo "<div align='center' class='shu'>"."共".$maxPage."页 当前为第".$page."页"."</div>";mysql_close($connection); //关闭与数据库的连接 */?><?phpsession_start();if(!isset($_SESSION['FORMINDEX'])){ header("location:index.php");}?> 子页代码中把<?phpsession_start();if(!isset($_SESSION['FORMINDEX'])){ header("location:index.php");}放到最前面去。 我这个进入登陆系统后是个框架页http://127.0.0.1/hotel_index/index_kj.htm框架页连接着各个PHP页,这怎么写 我这个进入登陆系统后是个框架页http://127.0.0.1/hotel_index/index_kj.htm框架页连接着各个PHP页,这怎么写 php 怎么连接运程的 mysql 数据库 apache和nginx 支持php-java-bridge配置上有什么区别 请高手指导下php发邮件代码怎么写 imgage输出到文件,后面显示相关信息的问题 帮忙看看这句是什么意思?初学者 有没有办法查看一个对象里面所有的属性和方法呢? 基础问题,这是什么意思? php 更改特定txt文件内容 如何限制数据库取出的文本的宽度? php 服务中调用java jar 包,怎样实现 PHP在登录系统中,不管输入任何登录子页网址,都必须先登陆主页 PHP+MySQL能开发这样的网站了吗?
if()//判断没有登录
{
header("Location: index.php\n");
exit;
}
$_SESSION['FORMINDEX'] = "yes";然后在index_zy中判断
session_start();
if(!isset($_SESSION['FORMINDEX'])){
header("location: index.php");
}
echo,print_r,HTML页面输出都不可以有。
这是主页代码<?php
session_start();
include("lianjie.php");
?>
<?php
$_SESSION['FORMINDEX'] = "yes";
?>
<script type="text/javascript">
function Checkform()
{ if(document.form1.user_login.value=="")
{
alert("用户名不能为空");
document.form1.user_login.focus();
return false;
}
else if(document.form1.user_pass.value == "")
{
alert("密码不能为空");
document.form1.user_pass.focus();
return false;
}
else
{
return true;
}
}
</script>
<!--***************登录页面***************-->
<link href="CSS/css.css" rel="stylesheet" type="text/css">
<body >
<table width="800px"align="center" >
<tr>
<td align="right" valign="top"><img src="img/logo01.jpg" align="right"></td>
</tr>
<tr><td height="252" colspan="3">
<form name="form1" method="post" action="" onsubmit="return Checkform();" style=" text-align:center; ">
<table width="100%" height="300" style="background-image:url(img/background.jpg);">
<tr>
<td align="center" colspan="2">
<table border="0" cellspacing="0" cellpadding="1" align="center">
<tr>
<td colspan="2" align="center" height="50px"><font color="#FFFFFF" face="华文宋体" size="+1">用户登录</font></td>
</tr>
<tr>
<td height="30">
<div align="right" style="color:#FFFFFF; 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:#FFFFFF;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/hotel_dl.jpg">
</div></td>
</tr>
</table></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</body>
<?php
$user_login=$_POST["user_login"];//赋值
$user_pass=$_POST["user_pass"];
if($user_login && $user_pass)
{
$query="select * from background 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.htm';</script>";exit();//登录成功跳转到index_bc
}else{
echo "<script>alert('用户名或密码错误');window.location='index.php';</script>";exit();
}
}
这是子页
<?php
include("lianjie.php");
?>
<link href="CSS/css.css" rel="stylesheet" type="text/css">
<script>
function delconfirm(){
if(window.confirm( "请确认是否删除? ")){
return true;
}
return false;
}
</script> <form method="POST" action="">
<fieldset style="width:600px;">
<legend>酒店活动数据查询</legend>
<p>
<table width="600">
<tr>
<td align=left>搜 索 条 件 :<select name="ziduan" style="width:155px;">
<option value="select=select">查看全部数据</option>
<option value="hotel_id">酒店ID</option>
<option value="content">内容介绍</option>
<option value="source">备注</option>
<option value="s_type">s_type</option>
</td>
<td align=left>搜索关键字:<input name="txt_sousuo" type="text" value=""/>
</td>
<td align="left">
<input name="sousuo" type="image" value="" src="img/03.gif" />
</td>
</tr>
</table>
</fieldset>
</form>
<p>
<?php
。
。。?>
<?php
echo "</div>";
echo "</table>";
echo "<div align='center' class='shu'>"."共".$maxPage."页 当前为第".$page."页"."</div>";
mysql_close($connection); //关闭与数据库的连接 */
?>
<?php
session_start();
if(!isset($_SESSION['FORMINDEX'])){
header("location:index.php");
}
?>
<?php
session_start();
if(!isset($_SESSION['FORMINDEX'])){
header("location:index.php");
}
放到最前面去。
框架页连接着各个PHP页,这怎么写