当用户登录时,使下拉列表消失,其中包含登录表单

时间:2016-02-25 09:21:31

标签: javascript php html css

我一直在努力工作几周,试图找到修复方法。这是我的问题我的导航上有一个下拉栏,其中包含我的登录信息。我需要它消失并替换为欢迎消息。我甚至无法通过论坛

以简单的方式消失它
if(session is on) {
   view welcome and disappear form
}
else
{
   this is suppose to bring up the form but it doesn't disapear in the first place.
}

我不知道我这样做是不是错了。下面是我在php上导航的代码,不会发布css。欢迎和注销文本也在页面中的所有其他文本中,我似乎无法移动它。如果我可以用登录下拉列表替换它会很好。代码如下。

//this is the navigation and the dropdown login with the login fourm contained.
<ul>
<li><a class="active" href="index.php">Home</a></li>
  <li><a href="messages/message.php">Messages</a></li>
  <li><a href="ask.php">ASK</a></li>
  <li><a href="cloud.php">Cloud Access</a></li>
   <li><a href="gallery.php">Gallery</a></li>

  <ul style="float:right;list-style-type:none;padding-right:150px;">
<div class="dropdown">
    <a href="http://google.com" class="dropbtn">Login</a>
    <div class="dropdown-content">
    <div id="Register">
<form action="" method="POST">
    <p><label>User Name : </label>
    <input id="username" type="text" name="username" placeholder="username" /></p>

     <p><label>Password&nbsp;&nbsp; : </label>
     <input id="password" type="password" name="password" placeholder="password" /></p>

    <a class="btn" href="register.php">Signup</a>
    <input class="btn register" type="submit" name="submit" value="Login" />
    </form>
</div>
</div>
  </div>
  <li><a href="#about">About</a></li>
</ul>
</ul>

// this is the php which should make a session and make the fourm disapear. I need the fourm and the dropdown to disapear and be placed with text.
<?php

    if(isset($msg) & !empty($msg)){
        echo $msg;
    }
    ?>

<?php

session_start();
 require('connect.php');

if (isset($_POST['username']) and isset($_POST['password'])){

$username = $_POST['username'];
$password = $_POST['password'];

$query = "SELECT * FROM `user` WHERE username='$username' and password='$password'";

$result = mysql_query($query) or die(mysql_error());
$count = mysql_num_rows($result);
 will be created for the user.
if ($count == 1){
$_SESSION['username'] = $username;
}else{

echo "<p id='btn' >sorry please cheach if that is correct .</p>";
}
}

if (isset($_SESSION['username'])){
$username = $_SESSION['username'];
echo '<div id="password">';
echo "Welcome " . $username . " ";
echo "<p>This is the Members Area<p>";
echo "<a href='logout.php'>Logout</a>";
echo '</div>';

}else{

}
?>

我希望我能说清楚我说的话。但如果有任何问题,请在下面回复。谢谢,如果我能解决这个小问题,这一切都会成为我的一周。

1 个答案:

答案 0 :(得分:0)

只有在未使用PHP设置会话变量

时才能输出表单

示例:

Private Sub btnclick_Click(sender As Object, e As EventArgs) Handles btnclick.Click
    Try
        Dim Year As Integer = 2016
        Dim MonthName As String = txtbox.Text
        Dim Month As Integer = DateTime.ParseExact(MonthName, "MMMM", CultureInfo.CurrentCulture).Month
        dayslabel.Text = DateTime.DaysInMonth(Year, Month)
    Catch ex As Exception
        'Message
    End Try
End Sub