Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
M

msz900

@msz900
About
Posts
2
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Available username on all pages after login
    M msz900

    HY! i have an issue in php session. the issue is that the session work fine in index page but the username can't show in other pages. lohin.php code

    <?php session_start();
    include './header.php';
    include 'connection.php';
    if(isset($_POST) && count($_POST)>0) {
    $user = $_POST['username'];
    $pass = $_POST['password'];

    $sSQL = "SELECT \* FROM ulog WHERE User\_Name ='".$user."' AND Password = '".$pass."'";
    
    $result = mysql\_query($sSQL) or die(mysql\_error());
    $row=mysql\_num\_rows($result);
    if($row==1)
        {
        // Set username session variable
            $\_SESSION\['username'\] = $\_POST\['username'\];
            // Jump to secured page
            header('Location:index.php');
                }
    

    }

    else
    {
        header("location:login.html");
    }
    

    ?>

    index.php code

    <?php session_start();
    include './header.php';
    // Check, if username session is NOT set then this page will jump to login page
    if (!isset($_SESSION['username']))
    {
    header('Location:login.html');
    }
    ?>
    <div id="welcome">
    <h4> Welcome <?php echo $_SESSION['username']; ?> <a href="logout.php">Logout</h4></a></p>
    </div>
    <div id="content">
    <p>Learn to Design and Develop Website.<br />
    Learn Programing From Tutorial's teaches you the fundamentals of web development and not just programming. You will learn how to create amazing websites through programming and design tutorials. The web development tutorials on your left are designed for you to move through them in order to have an overall understanding of web design and development.</p>
    </div>
    <?php include './footer.php'; ?>

    the code i use in other pages which is not working is..

    <?php session_start();
    include 'login.php';
    // Check, if username session is NOT set then this page will jump to login page
    if (!isset($_SESSION['username']))
    {
    header('Location:login.html');
    }
    ?>

    the above code is used in other pages but it is not working.. what type of code i need to access username in all pages..

    Linux, Apache, MySQL, PHP tutorial php html database mysql

  • How old were you when you first wrote a line of code ?
    M msz900

    hmmm.. may be iam 18 year's old at that time.

    MSZ

    The Lounge question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups