I'm using jQuery for mobile and making the app show users a dailog box to let them enter their credentials when they want to log into the app. Ok. it redirects them to the home page but the url stays as mysite.com/login.php rather than mysite.com/index.php This removes the menu bar on the bottom but it appears if the page is refreshed which I don't want my users to do. Since I'm using a dialog box for the log in page, how would I display any errors if username/password isn't correct? If I do though, they will be redirected to the actual login.php page and dialog box disappears.
Why is that ? any help will be appreciated. Thank you.
<?php
include('funcs/connector.php');
$port = new MySqlDatabase();
$port ->connect('root','','myDB') 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";
}