Friday, February 18, 2022

[FIXED] Login page won't display unless PHP code is removed

Issue

I've been following a few examples online to setup a user registration and login system with PHP+MySQL.

I have registration working fine, but my login.php page won't display. It is a simple html form. The form displays when I remove the PHP code but when I put the code back in I just get a blank white page.

This is the PHP:

<?php
session_start();
include("db.php"); 
if (isset($_POST['username'] && isset($_POST['password'])) 
{     
user_login($_POST['username'], $_POST['password']); 
} 
?>

I had this happen before due to a syntax error but can't see any here. Any ideas?


Solution

isset($_POST['username'] isn't closed.

The code should be:

<?php
session_start();
include("db.php"); 
if (isset($_POST['username']) && isset($_POST['password'])) 
{     
user_login($_POST['username'], $_POST['password']); 
} 
?>

However, PHP usually shows you an error if you do something like this. Your php.ini settings have probably suppressed errors, which is why there is a blank page

IMO, for development it's not a great idea to have errors turned off. It's a good idea on a live site, but not during development.



Answered By - Nick

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.