I have some problem with my LoginForm.When I enter login parameters and click on Submit button
,the username and password field get blank and on again clicking on Submit button without providing parameters it gets login….So we have to click two times on Submit button to login
<?php
if(isset($_POST['username']) && isset($_POST['password']))
{
$username = $_POST['username'];
$password = $_POST['password'];
if(!empty($username) && !empty($password))
{
$query = "SELECT id FROM register WHERE username ='$username' AND password='$password'";
$query_run = mysql_query($query);
if($query_run)
{
$query_num_rows = mysql_num_rows($query_run);
if($query_num_rows == 0)
{
echo 'Invalid username/password';
}
else if($query_num_rows == 1)
{
$user_id = mysql_result($query_run,0,'id');
$_SESSION['user_id'] = $user_id;
header('Locaton : index.php');
}
}
}
}
?>
it seems you have misspelled the header() function
change
header('Locaton : index.php');to
header('Location : index.php');