Please I need this fixed it's php
===

Hello I have made a login system for my website dubleeble.com and for some reason when you login it only keeps you loged in on one page but when you move to another page it loges you out! How do I fix this?

this is the code I used:

    <?php
    session_start();
    $username = $_POST['user'];
    $password = $_POST['pass'];
    
    if($username&&$password) {
        $connect = mysql_connect("host", "user","pass") or die("Could't Connect!");
        mysql_select_db("db");
    
        $query = mysql_query("SELECT * FROM users WHERE username='$username'");
    
        $numrows = mysql_num_rows($query);
    
        if($numrows!=0) 
        {
            while ($row = mysql_fetch_assoc($query)) {
                $dbusername = $row['username'];
                $dbpassword = $row['password'];
            }
    
            if($username==$dbusername&&$password==$dbpassword) {
    
                $_SESSION['username']=$username;            
                header('Location: ' . $_SERVER['HTTP_REFERER']);
            }
            else
            header('Location:http://dubleeble.com/php/login/incorrect.php');
        }
    
        else
        header('Location:http://dubleeble.com/php/login/incorrect.php');
    
    
    }
    
    else
    header('Location: ' . $_SERVER['HTTP_REFERER']);
    ?>