Redirect after log in to index using php : <p>I want to make the system login. After user insert username and password, he/she is redirect to index.php
But, i got a problem for the process script.</p>

<pre><code>Notice: Undefined variable: conn in C:\xampp\htdocs\file\login.php on line 15

Fatal error: Call to a member function query() on null in C:\xampp\htdocs\file\login.php on line 15
</code></pre>

<p>And here is the script:</p>

<pre><code>&lt;?php
include('connection.php');
session_start();

if ( ! empty($_SESSION['username'] ) ) {
    header('Location:index.html?');
    exit;
}

if(isset($_POST["login"]))           //FUNGSI LOGIN
{ 
    $username   = $_POST["username"];
    $password   = $_POST["password"];

    $sql_login      = "SELECT * FROM tbl_user WHERE username='$username' AND password='$password'";
    $result_login   = $conn-&gt;query($sql_login);
    $row_login      = $result_login-&gt;fetch_assoc();
    $numrow_login   = $result_login-&gt;num_rows;

    if($numrow_login==1)
    {
        $_SESSION['username'] = $username;
        header('Location:index.html?');
        exit;
    }
}
?&gt;
</code></pre>
