如何阻止php登录在内容区输出结果?
我有一个正在进行的网站,设计工作已经完成,但我的网站动态工作。我在网站上有一个包含登录表单的登录部分。我有我的登录脚本工作,但当用户登录时,登录表单停留在网站上,成员部分出现在我的内容所在的位置。以下是站点设计/配置的示例: Index.php --文件包括design exp:include的部分(标题、导航、内容、侧栏、页脚) sidebar.php --包含用于登录的html表单如何阻止php登录在内容区输出结果?,php,html,forms,login,include,Php,Html,Forms,Login,Include,我有一个正在进行的网站,设计工作已经完成,但我的网站动态工作。我在网站上有一个包含登录表单的登录部分。我有我的登录脚本工作,但当用户登录时,登录表单停留在网站上,成员部分出现在我的内容所在的位置。以下是站点设计/配置的示例: Index.php --文件包括design exp:include的部分(标题、导航、内容、侧栏、页脚) sidebar.php --包含用于登录的html表单 <form id="loginForm" name="loginForm" method="post"
<form id="loginForm" name="loginForm" method="post" action="login/login-exec.php">
<p align="left" class="description"><label for="username"><b>Username:</b></label></p>
<p align="left"><input name="username" type="text" id="username" size="40" maxlength="40" /></p>
<p align="left" class="description"><label for="password"><b>Password:</b></label></p>
<p align="left"><input name="password" type="password" size="40" maxlength="100" id="password" /></p>
<p align="right"><input name="login" type="submit" value="Log In" id="submit" /></p>
<h6 align="left">» <a href="./index.php?od=register"><font color="#565656">Not Registered?</font></a></h6>
<h6 align="left">» <a href="./index.php?od=fgtpsswd"><font color="#565656">Forgot Password?</font></a></h6>
<input type="hidden" name="ref" value="{REF}" />
</form>
登录脚本位于名为/login/的文件夹中,我希望我的表单切换到一个成员面板,其中包含指向安全部分的链接。我猜php if和elseif语句是必要的,但不确定。有人有什么想法吗?这应该行得通。(sidebar.php)
用户名:
密码:
&拉阔;
&拉阔;
“有人有什么想法吗?”不是没有看到一些代码……您遗漏了最重要的脚本:login-exec.php。当您登录时,它会生成您要进入的页面。如果登录表单设置了一个会话变量,sidebar.php可以检查该变量并用注销按钮替换登录表单。我不明白你所说的“成员部分出现在我的内容所在的位置”是什么意思,我用login-exec.php代码更新了它,启动了一个logged-in和header语句。我有一个内容区,所有的主页都显示在这里。当我从表单登录到内容右侧时,我的成员面板将显示在我的内容应该位于的位置,我宁愿表单位于内容右侧,我的所有主要内容都将显示在成员面板的旁边。我没有为我做任何事,仍然可以在“我的内容”部分看到结果填充。请尝试新的更新并让我知道。如果不起作用,请添加到sidebar.php,确保您已注销,并查看它给您带来的信息。当我登录时,它会将我引导到我的内容区域中的“成员”页面和登录部分中的表单,但在我登录后,如果我单击“注册”,则表单将消失,并且仅显示帐户id。因此,当您登录时,html登录表单消失,只显示您的帐户id?如果您注销,那么表单就存在了?只有当我单击“注册”时,表单才会更改为我的帐户id,但只有当我登录并单击“注册”时,表单才会更改
<?php
if ($_REQUEST["od"]=="home") include("incs/news.html");
elseif ($_REQUEST["od"]=="portfolio") include("incs/portfolio.html");
elseif ($_REQUEST["od"]=="tutorials") include("incs/tutorials.html");
elseif ($_REQUEST["od"]=="resources") include("incs/resources.html");
elseif ($_REQUEST["od"]=="services") include("incs/services.php");
elseif ($_REQUEST["od"]=="contact") include("incs/contactus.html");
elseif ($_REQUEST["od"]=="webhosting") include("incs/webhosting.html");
elseif ($_REQUEST["od"]=="webdesign") include("incs/webdesign.html");
elseif ($_REQUEST["od"]=="webdevelopment") include("incs/webdevelopment.html");
elseif ($_REQUEST["od"]=="repairs") include("incs/repairs.html");
elseif ($_REQUEST["od"]=="login") include("login/login-exec.php");
elseif ($_REQUEST["od"]=="logfail") include("login/login-failed.php");
elseif ($_REQUEST["od"]=="register") include("login/register-form.php");
elseif ($_REQUEST["od"]=="registerex") include("login/register-exec.php");
elseif ($_REQUEST["od"]=="regsuccess") include("login/register-success.php");
elseif ($_REQUEST["od"]=="denied") include("login/access-denied.php");
elseif ($_REQUEST["od"]=="account") include("login/member-index.php");
elseif ($_REQUEST["od"]=="profile") include("login/member-profile.php");
elseif ($_REQUEST["od"]=="logout") include("login/logout.php");
else include("incs/news.html");
?>
<form id="loginForm" name="loginForm" method="post" action="login/login-exec.php">
<p align="left" class="description"><label for="username"><b>Username:</b></label></p>
<p align="left"><input name="username" type="text" id="username" size="40" maxlength="40" /></p>
<p align="left" class="description"><label for="password"><b>Password:</b></label></p>
<p align="left"><input name="password" type="password" size="40" maxlength="100" id="password" /></p>
<p align="right"><input name="login" type="submit" value="Log In" id="submit" /></p>
<h6 align="left">» <a href="./index.php?od=register"><font color="#565656">Not Registered?</font></a></h6>
<h6 align="left">» <a href="./index.php?od=fgtpsswd"><font color="#565656">Forgot Password?</font></a></h6>
<input type="hidden" name="ref" value="{REF}" />
</form>
if($result) {
if(mysql_num_rows($result) == 1) {
//Login Successful
session_regenerate_id();
$account = mysql_fetch_assoc($result);
$_SESSION['SESS_ACCOUNT_ID'] = $account['id'];
$_SESSION['SESS_FIRST_NAME'] = $account['firstname'];
$_SESSION['SESS_LAST_NAME'] = $account['lastname'];
session_write_close();
header("location: ../index.php?od=account");
exit();
}else {
//Login failed
header("location: /index.php?od=logfail");
exit();
}
<? if($_SESSION['SESS_ACCOUNT_ID'] == ''): ?>
<form id="loginForm" name="loginForm" method="post" action="login/login-exec.php">
<p align="left" class="description"><label for="username"><b>Username:</b></label></p>
<p align="left"><input name="username" type="text" id="username" size="40" maxlength="40" /></p>
<p align="left" class="description"><label for="password"><b>Password:</b></label></p>
<p align="left"><input name="password" type="password" size="40" maxlength="100" id="password" /></p>
<p align="right"><input name="login" type="submit" value="Log In" id="submit" /></p>
<h6 align="left">» <a href="./index.php?od=register"><font color="#565656">Not Registered?</font></a></h6>
<h6 align="left">» <a href="./index.php?od=fgtpsswd"><font color="#565656">Forgot Password?</font></a></h6>
<input type="hidden" name="ref" value="{REF}" />
</form>
<? endif; ?>