PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, February 18, 2022

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

 February 18, 2022     html, mamp, mysql, php     No comments   

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
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

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

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing