As instructed i have to insert the code inbetween the dashed lines.
Supposed to refresh and see ‘exists’
I have the correct database, table, everything im pretty sure but
i see no exist.
Should i keep following the guide or did i mess up?
Does anyone have a guide that is GUARANTEED to work if i follow it correctly?
my login.php
<?php
include 'core/init.php';
-----------------------------------------
if (user_exists('alex') === true) {
echo "exists";
}
die('no exist');
-------------------------------------------
if (empty($_POST) === false) {
$username = $_POST['username'];
$password = $_POST['password'];
if (empty($username) === true || empty($password) === true) {
$errors[] = 'You need to enter a username and password';
} else if (user_exists($username) === false) {
$errors[] = 'We can not find that user';
}
}
?>
i have init.php
<?php
session_start();
error_reporting(0);
require 'database/connect.php';
require 'functions/general.php';
require 'functions/users.php';
$errors = array();
?>
i have users.php
<?php
function user_exists($username) {
$username = sanitize($username);
$query = mysql_query("SELECT COUNT('user_id') FROM 'users' WHERE 'username' = '$username'");
return (mysql_result($query, 0) == 1) ? true : false;
}
?>
i have general.php
<?php
function sanitize($data) {
return mysql_real_escape_string($data);
}
?>
i use:
<form action="login.php" method="post">
note: if anyone is familiar with phpacademy i am following his guide
Your
dieis always called, you should change your code to: