sorry it took so long to respond
ive changed my code a bit but now when i pass the username and password i get back this error "Trying to get property of non-object in C:\wamp\www\whatscookincatering\lib\functions.php on line 23" here is what my code looks like now index.php
<?php
require '../blog.php';
$data = array();
session_start();
# check required fields
if( empty( $_POST['username'] ) || empty( $_POST['password'] ) ){
$data['msg'] = 'Please fill out both fields to log in.';
}else{
$DB = new mysqli( 'localhost', $config['dbusername'], $config['dbpassword'], $config['database'] );
# check if login is correct:
$success = check_login( $_POST['username'],$_POST['password'],$DB );
# assign appropriate message:
$data['msg'] = $success?
'Thank you for logging in': // success
'Wrong username or password.'; // failure
}
view('../admin/login', $data);
?>
functions.php
<?php
function view($path, $data = null)
{
if ( $data ){
extract($data);
}
$path = 'views/' . $path . '.tmpl.php';
include "../views/layout.php";
}
function check_login( $username,$password,mysqli $DB )
{
$query = $DB->prepare( "SELECT 1 FROM users WHERE username=? AND password=?" );
$password = md5( $password );
# bind the submitted username/password to the statement
$query->bind_param( 'ss',$username,$password );
# query the DB and check number of rows returned to determine success
$result = $query->execute();
return ($result->num_rows === 1)?
true:
false;
}
?>
this is line 23
"return ($result->num_rows === 1)?"