So i'm coding a user login that i found online and youtube to help customize to my own liking for my website. however everything works fine its an old link so i know times have changed.. but with all the research i've done.. and the coding i did i dont get why it doesnt work.. here are the included coding..
<?php
include 'core/init.php';
include 'includes/overall/header.php';?>
<h1>Home</h1>
<p>Just a template</p>
<?php include 'includes/overall/footer.php';?>
that is the index.php file..
<?php
session_start();
error_reporting(0);
require 'database/connect.php';
require 'functions/general.php';
require 'functions/users.php';
$errors = array();
?>
that is the init.php file...
<?php
$connect_error = 'Error message';
$con = mysqli_connect('localhost','root','********');
mysqli_select_db($con,'millcitycannabis') or die($connect_error);
?>
that's the connect.php...
<?php
function user_exists($username) {
$username = sanitize($username);
return (mysql_result(mysql_query("SELECT COUNT('user_id') FROM users WHERE user_name = '$username'"), 0) == 1) ? true : false;
}
?>
thats the user.php file...
<?php
include 'core/init.php';
if (user_exists('Joshua') === true) {
echo 'Exists';
} else {
echo 'Does not exist';
}
die();
if (empty($_POST) === false) {
$username = $_POST['username'];
$password = $_POST['password'];
if (empty($username) || empty($password)) {
$errors[] = 'You need to enter a Username and Password.';
} else if (user_exists($username) === false) {
$errors[] = "User name not found. Please check and try again.";
}
}
?>
and finally the login.php..
i know for a fact there are two records i manually put in...
if (user_exists('Joshua') === true) {
echo 'Exists';
} else {
echo 'Does not exist';
}
die();
should bring back "Exists" instead it brings back "Does not exist" so i dont know if i didnt set up the connect.php to the database correctly.. or did i typo somewhere? any help would be great ty :) <3