Sorry about the probably extremely stupid question but I've been messing with this for hours and still cannot get it to work.
I am trying to create a login system using a mysqli database. For some reason it will not work, i'm currently getting the property of non-object error.
Here is the code
<?php
session_start();
$db = ("obsidian");
$mysqli = new mysqli('localhost','admin1', 'password1') or die('Failed to connect to DB' . $mysqli->error );
if(isset($_POST['sub'])){
$username = $_POST['username']; $password = $_POST['password'];
}
$sSQL = "select * from users where password='$password' AND username='$username'";
$rsMain = $mysqli->query( $sSQL );
if ($rsMain->num_rows == 1)
{
$_SESSION['userid'] =$username;
header("Location: index.php");
}
else
{
//ignore
}
?>
It's the checking for the rows that I'm having the issue with, I cannot figure out how to do it.
Any help would be great.
The error is Notice: Trying to get property of non-object in C:\xampp1\htdocs\ObsidianDream\login2.php on line 20