What I want to achieve: What I am trying to achieve: The user should initiate the function then he clicks on the form button. If the infos posted matches with the ones in the database then he gets redirected to login.php, otherwise to relogin.php. I want to be able to find a way to prevent the usage of "global" variables within the function if possible.
Problem: It seems it cant read the mysql connection inside my variable as if it were empty or something or am I wrong? Below the errors messages:
Warning: mysqli_stmt_bind_param(): invalid object or resource mysqli_stmt in C:\xampp\htdocs\project_procedural\php\core\login.php on line 22
PHP Warning: mysqli_stmt_bind_result(): invalid object or resource mysqli_stmt in C:\xampp\htdocs\project_procedural\php\core\login.php on line 23
PHP Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in C:\xampp\htdocs\project_procedural\php\core\login.php on line 24
PHP Warning: mysqli_stmt_close(): invalid object or resource mysqli_stmt in C:\xampp\htdocs\project_procedural\php\core\login.php on line 25
What I tried: Tried to remove the global keyword and added $connection as a parameter to my login_check function which caused an error. I also read about php define() but which is only used for constants (which it is in this case?) but makes it global. I know there is the OOP way but I want to master the procedural methods first.
Link to my code in -> phpfiddle