www.webdeveloper.com
Results 1 to 2 of 2

Thread: Help with If/else Statement please

  1. #1
    Join Date
    Jun 2011
    Posts
    140

    Help with If/else Statement please

    In my header, I have a login script as follows:

    Code:
    <form action="login.php" method="post" name="logForm" id="logForm" >
    <label>Username: </label><input name="usr_email" type="text" class="required" id="txtbox" size="20"> 
    <label>Password: </label><input name="pwd" type="password" class="required password" id="txtbox" size="20">
    <input name="doLogin" type="submit" id="doLogin3" value="Login">
    </form>
    But if the user is logged in then I want it to say:

    <h3>Welcome <?php echo $_SESSION['user_name'];?></h3>

    So how can I please do the "if user is logged in then say welcome else show login script"?

    Thanks,
    Adey

  2. #2
    Join Date
    Oct 2009
    Posts
    658
    PHP Code:
    <?php if(isset($_SESSION['user_name'])) { ?>
    <h3>Welcome <?php echo $_SESSION['user_name'];?></h3>
    <?php }else {?>
    <form action="login.php" method="post" name="logForm" id="logForm" >
    <label>Username: </label><input name="usr_email" type="text" class="required" id="txtbox" size="20"> 
    <label>Password: </label><input name="pwd" type="password" class="required password" id="txtbox" size="20">
    <input name="doLogin" type="submit" id="doLogin3" value="Login">
    </form>
    <?php ?>
    Good Luck

    Santos Systems

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles