Im new to php and downloaded a couple of projects from github to practise,
One of them is this system to login users, keep them logged in for sessions, log them out etc...
I'm working on my server
My config file reads:
<?php
//Database information
define("DB_SERVER", "localhost");
define("DB_USER", "");
define("DB_PASS", "");
define("DB_NAME", "userlogin");
//Database table information
define("USER_TABLE", "users");
define("LOGGED_IN_TABLE", "logged_in_member");
//Fully Qualified Domain Name
define("SITE_HTTP", "");
//Return email address
define("FROM_EMAIL", "");
?>
when i visit the register.php file with my browser it prompts me to select username and password once i do and click submit i get the following error message
Warning: mysqli::mysqli(): (HY000/1044): Access denied for user ''@'localhost' to database 'userlogin' in C:\xampp\htdocs\GIT HUB PRACTISE PROJECTS\USER LOGIN\phpUserLoginSystem\classes\AuthDB.class.php on line 8
Warning: mysqli::prepare(): Couldn't fetch mysqli in C:\xampp\htdocs\GIT HUB PRACTISE PROJECTS\USER LOGIN\phpUserLoginSystem\classes\AuthDB.class.php on line 21
Fatal error: Call to a member function bind_param() on a non-object in C:\xampp\htdocs\GIT HUB PRACTISE PROJECTS\USER LOGIN\phpUserLoginSystem\classes\AuthDB.class.php on line 27
The lines on the file read as follows (in bold)
<?php
require_once 'config.php';
class AuthDB {
private $_db;
public function __construct() {
[B] $this->_db = new mysqli(DB_SERVER, DB_USER, DB_PASS, DB_NAME)
[/B] or die("Problem connect to db. Error: ". mysqli_error());
}
public function __destruct() {
$this->_db->close();
unset($this->_db);
}
public function createUser($email, $password, $salt, $verification) {
$query = "INSERT INTO tbUsers (email, password, user_salt, is_verified, is_active, is_admin, verification_code) "
. "VALUES (?, ?, ?, ?, ?, ?, ?)";
[B] $stmt = $this->_db->prepare($query);
[/B]
$ver = 0;
$act = 1;
$adm = 0;
[B] $stmt->bind_param("sssiiis", $email, $password, $salt, $ver, $act, $adm, $verification);
[/B]
if ($stmt->execute()) {
return true;
}
return false;
}
the file then continues....
i created a database called userlogin (I invented it because I didn't see it specified anywhere else) and I added the tables mentioned in the config file with the appropriate fields.
Any idea what's going on? I don't know where I can get help for this. I'm new to this.
THANKS!