Hey everyone,

I'm having trouble to get this code to work as I wanted. My application is running on the top jQuery for mobile framework. The message I'm getting is this "undefined". I enter the right username and password but don't know what is undefined.

<?php

include('funcs/connector.php');
$port = new MySqlDatabase();
$port ->connect('root','','deco3500') or die(mysql_error());

session_start();


    $user  = mysql_real_escape_string($_POST['username']);
    $pass  = mysql_real_escape_string($_POST['password']);
    $query = "SELECT username, password FROM USERS WHERE `username` = '$user' AND `password`='$pass' ";
    $result = mysql_query($query) or mysql_error();

    $row = mysql_fetch_assoc($result);


    if( $username == $row['username']){
        $_SESSION['username'] = $row['username'];

        header('Location:index.php');

    }else{

        echo "this is wrong";
    }

?>

Ah, I know where the problem is. Instead of compairing $user == $row['username'], I was compairing $username == $row['username'] which in this case $username is not defined.

Now, it redirects to the index.php but it doesn't change the url to index.php. So the url stays as login.php.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.