0

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";
    }

?>

1
Contributor
2
Replies
3
Views
4 Years
Discussion Span
Last Post by rotten69
0

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.

0

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.