writing php functions
<p>I am new to php and trying to write a login function. Bit stuck and getting the error.
here my function:</p>

<pre><code>&lt;?php

if(!defined('_VALID_ACCESS')) die('direct access is not allowed.');
include('includes/connect.php'); 

function login($username, $password)
{
    $username = trim($username);
    $password = trim($password);
    echo $username;
    echo $password;
    $login_sql  = "SELECT * FROM user WHERE user = '".($username)."' 
    AND pass = '".(md5($password))."'";
    $login_result = $mysqli-&gt;query($login_sql) or die(mysqli_error());
    $row=$login_result-&gt;fetch_row();
    if($row[0] == 1)
    {
     return true;
    }
    else
    {
     return false;
    }
}
?&gt;
</code></pre>

<p>connect.php</p>

<pre><code>&lt;?php
$db_name = "coolmates";
$db_server = "localhost";
$db_user = "justron";
$db_pass = "Justron9004";

$mysqli = new MySQLi($db_server, $db_user, $db_pass, $db_name) or die(mysqli_error());

?&gt;
</code></pre>

<p>Notice: Undefined variable: mysqli in ..\login.php on line 14</p>

<p>Fatal error: Call to a member function query() on a non-object in ..\login.php on line 14</p>

<p>help me.</p>
