Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Problem with setting a variable $_POST

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • #39493
    robbinj
    Member

    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




    Webb B




























    and checklogin.php






    Webb B








    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!';
    }

    ?>






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

Viewing 1 post (of 1 total)
  • The forum ‘Back End’ is closed to new topics and replies.