Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Aug 2012
    Posts
    40
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Login echo array

    I have this in my website using it in my chat. I recommend it if you have a login system. and need to see if a user is or isnt logged in

    PHP Code:
    <?php
    session_start
    ();
    include_once
    "config.php";
    if(!isset(
    $_SESSION['username']) || !isset($_SESSION['password'])){
             echo 
    '<h4>You are not logged in. Please do so <a href="http://jays.netne.net/loginsystem/login.php">Login</a></h4>'; }


            else {
                echo 
    "<h4>You are logged in </h4>";
            }
    ?>

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    The problem with this though is you will echo out text before any DOCTYPE in your HTML because a session_start() needs to be called be any headers. It might be better to just setup a string with the message and then print it out later in the body of your HTML.
    ||||If you are getting paid to do a job, don't ask for help on it!||||


  •  

    Posting Permissions

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