繁体   English   中英

登录和首页问题?

[英]Login & home page issues?

好吧,我只是让我的登录页面可以正常工作,这当然导致了其他问题,我遇到的问题是,当您转到主页时,它应该允许您浏览主页并导航至其他未登录任何类型帐户的常规页面(不必注册或登录即可查看这些页面),但是由于某种原因,当我单击EOI_home.php(这是我的主页)作为非登录用户,它会自动将我带到我的login.php(我的登录页面),并迫使我先登录才能查看主页,这意味着我也无法以未注册或未注册的身份查看主页我应该能够登录的用户。 这是我的主页代码(EOI_home.php):

<head>
<title>Expression of Interest</title>
<link rel="stylesheet" href="Assign.css" type="text/css" />
</head>
<body>

<?php
require_once("nocache.php");
session_start();
if (!$_SESSION["who"]){
header("location: logoff.php");}
else {
$staff = $_SESSION["who"];
$access = $_SESSION["school_type"];
?>

<div class="title_background"><h2>Moving into Year 7 in a NSW government school in 2015</h2>
<h2>Information guide and Expression of Interest form for parents and carers</h2></div>
<p><img src="img1.jpg" width="750" height="550"></p>

<div class="right">
<?php
if ($access == S){
echo '<p><a href="process.php">Process EOI</a></p>';
echo '<p><a href="offerstatus.php">Print Offer Status Letters</a></p>';
}
if ($access == P){
echo '<p><a href="leavers.php">School Leavers</a></p>';
echo '<p><a href="comments_form.php">Add School Comments</a></p>';
}
echo '<p><a href="logoff.php">Logoff</a></p>';
}
?>
<p><a href="EOI_home.php">Home</a></p>
<p><a href="guidelines.htm">Guidelines</a></p>
<p><a href="options.htm">Your Secondary School Options</a></p>
<p><a href="eoi_form.php">Expression of Interest Form</a></p>
<p><a href="conpriv.htm">Privacy Statement and Contact Us</a></p>
<p><a href="login.php">Login</a></p>
</div>

<h1>Moving to secondary school</h1>

这是我的登录页面(login.php)的代码:

<body>

<?php
require_once("nocache.php");
$id = $_POST["id"];
$pword = $_POST["pword"];
$msgp = "";

if(!empty($_POST)) {
if(!empty($id) && !empty($pword)) {
    require_once("dbconn.php");
    $sql = "select username, school_type from school_info where username = '$id' and password = '$pword'";

    $rs = mysql_query($sql, $dbConn);

    if(mysql_num_rows($rs) > 0) {
        session_start();
        $_SESSION["who"] = $id;
        $_SESSION["school_type"] = mysql_result($rs, 0, "school_type");

        header("location: EOI_home.php");
    }
 } else {
    header("location: login.php");
    $msgp = '<span class="error>Incorrect username and/or password</span>';     
}
}
?>

<form method="POST" action="<?php echo $_SERVER["PHP_SELF"];?>" id="login">

ID: <input type="text" name="id" /><?php echo $msgp; ?></td><br/>
pword: <input type="password" name="pword" /><br/>

<p><a href="EOI_home.php">Home</a></p>

<input type="submit" value="log in" />&nbsp;
<input type="reset" />

</form>

这是nochache.php代码:

<?php
header("Cache-Control: no-cache");
header("Expires: -1");
?>

这也是logoff.php的代码,以防万一:

<?php
session_start();
require_once("nocache.php");
session_destroy();
header("location: login.php");
?>

顺便说一下,帐户具有不同的访问级别,并且具有不同的访问级别,主页上可以使用不同的链接,例如访问级别S和P。如果有人可以通过非常好的解决方案为我提供帮助,那么我是新手。

<?php
    require_once("nocache.php");
    session_start();
    if ($_SESSION["who"]){
        $staff = $_SESSION["who"];
        $access = $_SESSION["school_type"];
?>

只需注释标头(“ location:logoff.php”);

还检查注销代码是否正常

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM