Вот создал функцию, когда хочу сделать вход оно пишит
atal error: Call to a member function query() on a non-object in /home/tber01.wi3/public_html/restaurant/include/functions.php on line 52 Call Stack: 0.0003 661328 1. {main}() /home/tber01.wi3/public_html/restaurant/include/handler.php:0 0.0007 691576 2. restLogin() /home/tber01.wi3/public_html/restaurant/include/handler.php:19
в чём может быть проблема?
function restLogin($username, $password){
global $objCon;
if($username != '' && $password != ''){
$checkUser = $objCon->query("SELECT username FROM rest_user WHERE username = '$username' LIMIT 1");
$checkAdmin = $objCon->query("SELECT username, password, userType FROM rest_user WHERE username = '$username' AND password = '$password' AND userType = 1");
$checkPass = $objCon->query("SELECT username, password FROM rest_user WHERE username = '$username' AND password = '$password' LIMIT 1");
if(mysqli_num_rows($checkUser) != 1){
header('Location: ?page=5&error=2');
}elseif(mysqli_num_rows($checkPass) != 1){
header('Location: ?page=5&error=3');
}elseif(mysqli_num_rows($checkAdmin) >= 1){
$_SESSION['username'] = $username;
header('Location: ?page=100');
}else{
$_SESSION['username'] = $username;
header('Location: ?page=200');
}
}else{
header('Location: ?page=5&error=1');
}
}
а тут то что находиться в handler.php
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
include_once 'functions.php';
if($_SERVER['REQUEST_METHOD'] === 'POST'){
$input = $_POST['input'];
}
switch ($input){
case 'login';
$username = $_POST['username'];
$password = hash('sha256', $_POST['password']);
restLogin($username, $password);
break;
}