php - How to show username after login in web page -


i created simple web page using php , html...in page logged in dont know how show username after login.. @ same time want hide login , signup.. please help..

here code:

.welcome  {    float:right;    width:33.33%;    right: 0px;    text-align: right;    }
<nav class="navbar navbar-default navbar-inverse" role="navigation">      <div class="container-fluid">                    <div class="welcome">  			<!--<a href="" id="welcome">welcome!!</a>-->  			<?php  							                      if (isset($_session['name1'])) {                          /*echo ' <div class="rightone" onclick = "arrow();">';                          echo '<ul>';                          echo '<li><div class="arrow-down"></div>';                          echo '<div class="arrow-up"></div>';                          echo   '<ul>';                          echo     '<li><div>';                          echo      '<a  class="h2" href="php/logout.php" >logout</a>';                          echo      '</div></li>';                          echo     '<li><div><a href="php/account.php">account</a></div></li>';                          echo     '<li><div><a href="php/resetpassword.php">reset password</a></div></li>';                          echo   '</ul>';                          echo  '</li>';                          echo '</ul>';*/                          echo "hi,";                          echo $_session['name1'];                          //echo '</div>';                      }                                            ?>    			</div>          <ul class="nav navbar-nav navbar-right">                <li class="dropdown">                  <a href="#" class="dropdown-toggle" data-toggle="dropdown"><b>sign up</b> <span class="caret"></span></a>                  <ul id="login-dp" class="dropdown-menu">                      <li>                          <div class="row">                              <div class="col-md-12">                                  please fill fields!                                    <form class="form" role="form" method="post" action="login" accept-charset="utf-8" id="login-nav">                                      <div class="form-group">                                          <label class="sr-only" for="exampleinputemail2">name</label>                                          <input type="email" class="form-control" id="name" placeholder="name" required>                                      </div>                                      <div class="form-group">                                          <label class="sr-only" for="exampleinputemail2">email address</label>                                          <input type="email" class="form-control" id="exampleinputemail2" placeholder="email address" required>                                        </div>                                      <div class="form-group">                                          <label class="sr-only" for="exampleinputemail2">mobile number</label>                                          <input type="text" class="form-control" id="mobile" placeholder="mobile number" required>                                        </div>                                      <div class="form-group">                                          <button type="submit" class="btn btn-primary btn-block">sign up</button>                                      </div>                                    </form>                              </div>                            </div>                      </li>                  </ul>              </li>                  <li class="dropdown">                  <a href="#" class="dropdown-toggle" data-toggle="dropdown"><b>login</b> <span class="caret"></span></a>                  <ul id="login-dp" class="dropdown-menu">                      <li>                          <div class="row">                                                        <div class="col-md-12">                                  welcome back!                                    <!--<form class="form" role="form" method="post" action="login" accept-charset="utf-8" id="login-nav">-->                                  <form class="form" role="form"  action="php/sign.php" method="post" >                              			<?php                              if (isset($_get['msg'])) {                                  $message = $_get['msg'];                                  if ($message == 2) {                                      echo '                <p>                <span class="title" style="color:red;">                *invalid username or password                </span>                </p>                ';                                  }                              }                                ?>                                      <div class="form-group">                                          <label class="sr-only" for="exampleinputemail2">email address</label>                                          <input name="email" type="email" class="form-control" id="exampleinputemail2" placeholder="email address" required>                                      </div>                                      <div class="form-group">                                          <label class="sr-only" for="exampleinputpassword2">password</label>                                          <input name="password" type="password" class="form-control" id="exampleinputpassword2" placeholder="password" required>                                          <div class="help-block text-right"><a href="">forget password ?</a></div>                                      </div>                                      <div class="form-group">                                          <button type="submit" class="btn btn-primary btn-block">sign in</button>                                      </div>                                      <div class="checkbox">                                          <label>                                              <input type="checkbox"> keep me logged-in                                          </label>                                      </div>                                  </form>                              </div>                            </div>                      </li>                  </ul>              </li>          </ul>                  </div>  </nav>

my page:enter image description here advance!!!

after login store user details session.

in html page, check if($_session[userdetails]) not available show login , signup form.

<?php ?> <html> <body> ...... <?php if (!isset($_session[user_details])) { ?> <div> <!-- login --> </div> <div> <!-- signup --> </div> <?php } else {  echo $_session[user_details][username]; ?>  ....... </body> </html> 

Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -