Forums

Give help. Get help.

  • # August 24, 2012 at 9:57 am

    Hi!
    I’m trying to use the variable $username in my index.php (I want to echo out Logged in as ‘$username’).
    I set the variable $username and register a session in my checklogin.php, but I cant seem to use it when I’m in my index.php.

    I am probably doing something wrong here, but I can’t see what, I need your help finding a solution to this problem :)

    Code from index.php

    < !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


    Webb B




























    and checklogin.php

    < ? ob_start(); ?>

    < !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


    Webb B







    < ?php

    require_once "scripts/login.php";

    // error_reporting(E_ALL); ini_set('display_errors', 'On');

    $username = $_POST;
    $password = $_POST;

    // $username = stripslashes($username);
    // $password = stripslashes($password);
    // $username = mysql_real_escape_string($username);
    // $password = mysql_real_escape_string($password);

    $sqlCommand = "SELECT * FROM members WHERE membername='$username' AND memberpassword='$password'";
    $query = mysqli_query($myConnection, $sqlCommand) or die (mysqli_error());
    $num_rows = mysqli_num_rows($query);
    if ($num_rows == 1) {
    session_register("username");
    session_register("password");
    header("location: index.php");
    }
    else {
    echo 'Fel! Försök igen!';
    }

    ?>






    < ? ob_flush(); ?>

    Can anyone explain to me why I can’t use the variable $username?

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

icon-anchoricon-closeicon-emailicon-linkicon-logo-staricon-menuicon-nav-guideicon-searchicon-staricon-tag