我有三个php页面,header.php我放了我的ul标签,我有两个隐藏的li标签(每个页面都包括我的header.php),当我登录我的login.php,如果登录成功,我的页面将直接到profile.php,我想在我的header.php中显示两个隐藏的li标签。问题是我不知道显示我的li标签的确切语法。 我的header.php:
<ul class="nav navbar-nav " > <!--navbar-nav-->
<li><a href="home.php">Home</a></li>
<li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" href="#">About us</a>
<ul class="dropdown-menu">
<li><a href="about-us.php">The story</a></li>
<li><a href="culture.php">culture & services</a></li>
</ul>
</li>
<li><a href="enabling-the-idea-in-a-space.php">Projects</a></li>
<li class="hide"><a href="tender.php" >Tender</a></li>
<li><a href="news.php">News</a></li>
<!-- <li><a href="career.php">Career</a></li> -->
<li><a href="contact-us.php">Contact us</a></li>
<li class="hide" name="profile" id="profile"><a href="Profile.php" >Profile</a></li>
</ul>
这是我在login.php中显示li标签的代码:
$query = "SELECT * FROM [Emkaandb].[dbo].[tbl_clientslogin] WHERE email='{$email}' AND password='{$password}'";
$result = sqlsrv_query($conn, $query);
while($row = sqlsrv_fetch_array($result)){
$username = $row['email'];
$pass = $row['password'];
$name = $row['name'];
}
if(($email != $username) && ($password != $pass)){
echo '<script type="text/javascript">
alert("Invalid Username/Password!");
window.location.href = "home.php";
</script>';
die();
}else{
echo '<script type="text/javascript">
alert("WELCOME");
window.location.href = "Profile.php";
</script>';
echo "<td><form action=Profile.php method=post>
<input name=emailL type=text id=emailL value='".$row['email']."'>
</form></td>";
die();
}
答案 0 :(得分:0)
登录页面
<?php
session_start();
include 'connection.php';
$email = $_POST['user'];
$password = $_POST['pass'];
$username = "";
$pass = "";
$name = "";
//check if login form is filled
if(empty($_POST['user']) || empty($_POST['pass'])){
//header('Location: home.php'); when execute, ignore alert message
echo '<script type="text/javascript">
alert("Username/Password Empty!");
window.location.href = "home.php";
</script>';
die();
}
//search for user and password in the database
$query = "SELECT * FROM [Emkaandb].[dbo].[tbl_clientslogin] WHERE email='{$email}' AND password='{$password}'";
$result = sqlsrv_query($conn, $query);
while($row = sqlsrv_fetch_array($result)){
$username = $row['email'];
$pass = $row['password'];
$name = $row['name'];
}
if(($email != $username) && ($password != $pass)){
echo '<script type="text/javascript">
alert("Invalid Username/Password!");
window.location.href = "home.php";
</script>';
die();
}else{
echo '<script type="text/javascript">
alert("WELCOME");
window.location.href="Profile.php?chk=1&usr='.$username.'";
</script>';
/*echo "<td><form action=Profile.php method=get style=margin-top:-10%>
<input name=emailL type=text id=emailL value='".$row['email']."'>
</form></td>";*/
die();
}
?>
for header.php
<ul class="nav navbar-nav " > <!--navbar-nav-->
<li><a href="home.php">Home</a></li>
<li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" href="#">About us</a>
<ul class="dropdown-menu">
<li><a href="about-us.php">The story</a></li>
<li><a href="culture.php">culture & services</a></li>
</ul>
</li>
<li><a href="enabling-the-idea-in-a-space.php">Projects</a></li>
<?php if($check==1){
echo '<li><a href="tender.php" >Tender</a></li>';
?>
<li><a href="news.php">News</a></li>
<!-- <li><a href="career.php">Career</a></li> -->
<li><a href="contact-us.php">Contact us</a></li>
<?php if($check==1){
echo '<li class="hide" name="profile" id="profile"><a href="Profile.php" >Profile</a></li>';
}
?>
</ul>
for Profile.php
<h4 style="color:gray;"><b>Profile</b></h4>
<h3><?php echo $user; ?></h3>
<ul class="nav nav-tabs" style="color: #5c5b5b;">
<li class="active"><a data-toggle="tab" href="#drawing">Drawings</a></li>
<li><a data-toggle="tab" href="#document">Documents</a></li>
<li><a data-toggle="tab" href="#tender">Tender</a></li>
<li><a data-toggle="tab" href="#password">Change Password</a></li>
</ul>