如果登录,则覆盖包含php
我正在开发一个登录系统。我希望当我登录index.php时,该页面的include会更改为另一个页面。因此,在我的例子中,标题完全改变,登录按钮消失 所以我想改变如果登录,则覆盖包含php,php,Php,我正在开发一个登录系统。我希望当我登录index.php时,该页面的include会更改为另一个页面。因此,在我的例子中,标题完全改变,登录按钮消失 所以我想改变 到 如果登录 登录名: <div id="loginContainer"> <a href="#" id="loginButton"><span>Login</span><em></em></a>
到
如果登录
登录名:
<div id="loginContainer">
<a href="#" id="loginButton"><span>Login</span><em></em></a>
<div style="clear:both"></div>
<div id="loginBox">
<form id="loginForm" action="login.php" autocomplete="on" method="post">
<fieldset id="body">
<fieldset>
<label for="email">Email Address</label>
<input id="username" name="username" required="required" type="text" placeholder="myusername"/>
</fieldset>
<fieldset>
<label for="password">Password</label>
<input id="password" name="password" required="required" type="password" placeholder="eg. X8df!90EO" />
</fieldset>
<input type="submit" name="login" value="Login" />
<label for="checkbox"><input type="checkbox" id="checkbox" />Remember me</label>
</fieldset>
<span><a href="#">Forgot your password?</a></span>
</form>
</div>
</div></
电子邮件地址
密码
记得我吗
查询($q))
{
如果($res->num_rows>0)
{
$\会话['userName']=$userName;
//标题(“位置:welcome.php”);
包括('header4.php');
出口
}
其他的
{
echo'alert(“无效的用户名或密码”);
标题(“Location:index.php”);
出口
}
}
只需检查会话是否已设置,然后包括正确的文件。像这样的
if (isset($_SESSION['userName']) && !empty($_SESSION['userName'])) {
// If the user is logged in, include this file
include "header2.php";
} else {
// Else, we're not logged in, include this file
include "header.php";
}
只需检查会话是否已设置,然后包含正确的文件。像这样的
if (isset($_SESSION['userName']) && !empty($_SESSION['userName'])) {
// If the user is logged in, include this file
include "header2.php";
} else {
// Else, we're not logged in, include this file
include "header.php";
}
抱歉,您的问题不清楚。请随意更改
$fileName
并使用
抱歉,您的问题不清楚。随意更改$fileName
并使用
检查$\u会话['userName']是否为空可能是一个好主意,因为if可以设置为空(以防用户注销).取决于他登录时的结构,但你完全正确-我将在中编辑它。谢谢。如果你查一下!empty您不需要isset部分。检查$\u会话['userName']是否为空可能是个好主意,因为if可以设置为空(以防用户注销)。这取决于其登录的结构,但您完全正确-我将在中编辑它。谢谢。如果你查一下!空的你就不需要isset部分了。
if (isset($_SESSION['userName']) && !empty($_SESSION['userName'])) {
// If the user is logged in, include this file
include "header2.php";
} else {
// Else, we're not logged in, include this file
include "header.php";
}