Username ( [epiz_31818964]
Website URL kstuhallbooking.42web.io
Error Message
My website is a php based site, after entering the logins at the student side or the admin side, they all turns blank page after i click on the login button. Please kindly help me out
open your control panel and then turn on display errors in the php config section to help track down the issue
4 Likes
Thank you, Boss; I just completed that.
Please let me know what happens next.
oh oops !
just reload your website and see if any error messages are displayed at login
1 Like
Fatal error : Call to a member function prepare() on null in /home/vol13_2/epizy.com/epiz_31818964/htdocs/admin/index.php on line 8
I just had the above error after reloading my site
can you post the /admin/index.php file here , need to look at line 8
btw I should have asked … what is the name of this script you are using and where did you download it
<?php
session_start();
include('../includes/dbconn.php');
if(isset($_POST['login'])){
$username=$_POST['username'];
$password=$_POST['password'];
$password = md5($password);
$stmt=$mysqli->prepare("SELECT username,email,password,id FROM admin WHERE (userName=?|| email=?) and password=? ");
$stmt->bind_param('sss',$username,$username,$password);
$stmt->execute();
$stmt -> bind_result($username,$username,$password,$id);
$rs=$stmt->fetch();
$_SESSION['id']=$id;
$uip=$_SERVER['REMOTE_ADDR'];
$ldate=date('d/m/Y h:i:s', time());
if($rs){
header("location:dashboard.php");
} else {
echo "<script>alert('Invalid Username/Email or password');</script>";
}
}
?>
Admin
August 23, 2022, 10:29am
10
This means $mysqli
is null
. Which probably means the database connection failed. You can see why it failed by showing this variable: PHP: mysqli::$connect_error - Manual
7 Likes
Boss, if you could, please help me because I’m still having this issue.
Can you get a MySQL error? You can use google to get the correct code to show that error depending on what style of PHP you are using.
4 Likes
Oxy
August 23, 2022, 11:30pm
13
why do you have $username
twice?
did you mean $email or ?
4 Likes
Hayford
August 23, 2022, 11:46pm
14
<?php
session_start();
include('../includes/dbconn.php');
if(isset($_POST['login'])){
$username=$_POST['username'];
$password=$_POST['password'];
$password = md5($password);
$stmt=$mysqli->prepare("SELECT username,email,password,id FROM admin WHERE (userName=?|| email=?) and password=? ");
$stmt->bind_param('sss',$username,$email,$password);
$stmt->execute();
$stmt -> bind_result($username,$email,$password,$id);
$rs=$stmt->fetch();
$_SESSION['id']=$id;
$uip=$_SERVER['REMOTE_ADDR'];
$ldate=date('d/m/Y h:i:s', time());
if($rs){
header("location:dashboard.php");
} else {
echo "<script>alert('Invalid Username/Email or password');</script>";
}
}
?>
Hayford
August 23, 2022, 11:48pm
15
I’ve changed it now, but the issue persists.
Oxy
August 23, 2022, 11:48pm
16
I didn’t say to change it but I’m asking you why you have two ?
is there even a file dbconn.php in this dir includes
?
does it exist there?
4 Likes
Seeing as how you are processing the login in the main index.php file, and you cannot have a file located outside of the root, this line is incorrect.
If you do have that includes file outside of the htdocs folder (Which is what it is pointing to now), the server cannot access it due to the security systems in place.
include('../includes/dbconn.php');
Oxy
August 23, 2022, 11:59pm
18
no, he has an admin dir where that php login script is
and a step back is the includes folder
so path is ok
I would like him to physically make sure that the dbconn.php
exists in that includes directory
@Hayford cmon !
Well, there seems to be two login forms that are returning the same error. One in the root, and one in the Admin folder. so which does the code above belong to?
It does not:
And there is a /admin/includes folder as well, also without the file:
3 Likes
Oxy
August 24, 2022, 12:10am
20
I was based on this (the path from the error log that he mentioned)
but he should certainly edit the path for that includes
dir (scope)
and upload if the file which containing the DB connection is missing
Oxy
August 24, 2022, 12:24am
21
I am saying this only for the admin login:
if the code he sent refers to index.php
which is in the admin
folder
then this include is ok
because ../
means go one step back (above) + and from there find dir includes
(it does not matter that there is no folder before the admin folder)
now it’s on root >and then finds dir includes
he needs to upload that connection file if it doesn’t exist there
but always instead of ../
he can make it start with /
and that would then mean from the root of domain (wherever his script is located)
2 Likes