Login page not working. A blank page appears after the user clicks login button even with the correct email and password. var_dump[$_POST] returns array(10) { ["email"]=> string(0) "" ["password"]=> string(0) "" ["login"]=> string(0) "" ["uname"]=> string(0) "" ["name"]=> string(0) "" ["puname"]=> string(0) "" ["pname"]=> string(0) "" ["pemail"]=> string(0) "" ["Partnerpassword"]=> string(0) ""
Here is my code
<?php
require_once("config.php");
error_reporting(E_ALL);
ini_set('display_errors', 1);
$id=$_POST['email'];
$pass=$_POST['password'];
var_dump($_POST);
$stmt = $cn->prepare('SELECT Email,Password FROM register_partneruser WHERE Email = ? ');
$stmt->bind_param('s', $id);
$stmt->execute();
$stmt->bind_result( $a,$Partnerpassword);
if($stmt->fetch())
{
// var_dump($id,$a);
// var_dump($password,$Partnerpassword);
if(password_verify($pass,$Partnerpassword))
{
echo "Login successfull";
}
else
{
echo"Login failed";
}
}
else
{
$error = "Username or Password is incorrect";
}
?>
Here is the HTML code snippet of the login form
<form class="js-validate" novalidate="novalidate" method="post">
<!-- Login -->
<div id="login" style="opacity: 1;" data-target-group="idForm" class="animated fadeIn">
<!-- Header -->
<div class="card-header text-center">
<h3 class="h5 mb-0 font-weight-semi-bold">Login</h3>
</div>
<!-- End Header -->
<div class="card-body pt-6 pb-4">
<!-- Form Group -->
<div class="form-group pb-1">
<div class="js-form-message js-focus-state border border-width-2 border-color-8 rounded-sm">
<label class="sr-only" for="signinSrEmail">Email</label>
<div class="input-group input-group-tranparent input-group-borderless input-group-radiusless">
<input type="email" class="form-control" name="email" id="signinSrEmail" placeholder="Email Or Username" aria-label="Email Or Username" aria-describedby="signinEmail" required="" data-msg="Please enter a valid email address." data-error-class="u-has-error" data-success-class="u-has-success">
<div class="input-group-append">
<span class="input-group-text" id="signinEmail">
<span class="far fa-envelope font-size-20"></span>
</span>
</div>
</div>
</div>
</div>
<!-- End Form Group -->
<!-- Form Group -->
<div class="form-group pb-1">
<div class="js-form-message js-focus-state border border-width-2 border-color-8 rounded-sm">
<label class="sr-only" for="signinSrPassword">Password</label>
<div class="input-group input-group-tranparent input-group-borderless input-group-radiusless">
<input type="password" class="form-control" name="password" id="signinSrPassword" placeholder="Password" aria-label="Password" aria-describedby="signinPassword" required="" data-msg="Your password is invalid. Please try again." data-error-class="u-has-error" data-success-class="u-has-success">
<div class="input-group-prepend">
<span class="input-group-text" id="signinPassword">
<span class="flaticon-password font-size-20"></span>
</span>
</div>
</div>
</div>
</div>
<!-- End Form Group -->
<div class="mb-3 pb-1">
<button type="submit" name="login" formaction="../php/login.php" method="post" class="btn btn-md btn-block btn-blue-1 rounded-xs font-weight-bold transition-3d-hover">Login</button>
</div>
Is your question wrong?
There is a difference between:
NULL
is returned andA few questions arise from this:
error_reporting(E_ALL);
and
ini_set('display_errors', 1);
?Remove the code for the database query and the one for the password comparison and run the program again.
//$stmt = $cn->prepare('SELECT Email,Password FROM register_partneruser WHERE Email = ? ');
//$stmt->bind_param('s', $id);
//$stmt->execute();
//$stmt->bind_result( $a,$Partnerpassword);
if( 1 ) //if($stmt->fetch())
{
// var_dump($id,$a);
// var_dump($password,$Partnerpassword);
if( 1 ) //if(password_verify($pass,$Partnerpassword))
{
echo "Login successfull";
}
else
{
echo"Login failed";
}
}
else
{
$error = "Username or Password is incorrect";
}
The program should now be running.
You can manually control/emulate via if(1)
or if(0)
whether a user has logged in or not.
If your program is running now, the error is not in this program, but:
I assume that the Named Parameter
is the error, $stmt->bind_param('s', $id);
: because it is only specified as ?
in the query.
The reason that you don't get an error is that you don't have the right to set the Error Reporting
via PHP
-script.
Edit 1 for question:
You didn't answer my questions: Who hosts the web server? If it is you, you have to change your php.ini
and enable error_reporting
.
Otherwise you have to look in the configuration of your web hoster, how to enable it, or ask him!
Your question is wrong! You should ask, how do I activate the error_reporting and also give the necessary information, where is hosted, which php-version, if apache webserver or another!