Saturday 13 July 2019

displaying an error msg in same page not in white one using PHP form

I have a form in index.php



















as you can see if I submit, it would go to loginProcess.php



include_once "config.php";


$email = $_POST['email'];
$password = $_POST['password'];

$sql = "SELECT * FROM users WHERE email='$email' &&
password='$password'";

$query = mysqli_query($connect,$sql);

if($query){


$row = mysqli_fetch_array($query);
$rows = mysqli_num_rows($query);

if($rows == 1){

$user_id = $row['id'];

$_SESSION['id'] = $user_id;
$_SESSION['email'] = $email;


if($row['user_type'] == 1){
$_SESSION['user_type'] = 1;
header("Location: admin/index.php");
}else{
$_SESSION['user_type'] = 0;
header("Location: user/index.php");
}



}
elseif($_SERVER['REQUEST_METHOD'] == 'POST'){

echo'
You provided wrong information. Please try again
';
}


}



I inserted the bootstrap alert msg inside $_SERVER['REQUEST_METHOD'] to check if it is submitted. However, the msg still appears in white page.

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...