Originally I had my website locally setup on my laptop which is Linux and had recently migrated my work from there to my main PC - Windows. My reason for moving my work over is that I found the kind of Linux I am using to be incredibly buggy where the connection would constantly disconnect even though the internet was fine or it would take an incredibly long time to refresh the website.
I am now using XAMPP instead of manually having a localhost with PHP, Apache and MySQL set up. The IDE I am also using now is PhpStorm which is directly connected to my phpmyadmin.
Now my problem is that now I get the WSOD - White Screen Of Death, when I, lets say, try to register someone through my website this blank white screen comes up with NO errors displayed and I have looked at every possible help that I could find to fix this. Yet no success, so now I'm stuck in limbo as to whether my code is the problem or something else is, I just can't tell.
This is the same when I try my login feature as well.
This worked fine on my laptop, despite the minor errors here and there.
I have error reporting enabled and I have tried enabling it in the php.ini
file which only gets ignored or makes XAMPP reject it (not work).
Here is my code anyways for both the database and registration, just to give an example:
Register.php:
<?php
require 'connection.php';
ini_set('display_errors', 1);
ini_set('html_errors', 0);
error_reporting(E_ALL);
$firstname = isset($_POST['firstname']) ? $_POST['firstname'] : '';
$lastname = isset($_POST['lastname']) ? $_POST['lastname'] : '';
$email = isset($_POST['email']) ? $_POST['email'] : '';
$username = isset($_POST['username']) ? $_POST['username'] : '';
$password = isset($_POST['password']) ? $_POST['password'] : '';
$confirmpassword = isset($_POST['confirmpassword']) ? $_POST['confirmpassword'] : '';
$message[] = '';
if (!empty($_POST['username']) && !empty($_POST['password']))
{
//var_dump($password, $confirmpassword);
if(strlen($password) > 6 && strlen($password) < 32)
{
if($password == $confirmpassword)
{
$records = $conn->prepare('SELECT * FROM users WHERE Username = :username');
$records->bindParam(':username', $_POST['username']);
$records->execute();
$results = $records->fetchAll(PDO::FETCH_ASSOC);
//var_dump($results);
if(count($results) > 0)
{
echo 'That username is already in use, please use a different one.';
}
else
{
$emailRecords = $conn->prepare('SELECT * FROM users WHERE Email = :email');
$emailRecords->bindParam(':email', $_POST['email']);
$emailRecords->execute();
$emailResults = $emailRecords->fetchAll(PDO::FETCH_ASSOC);
if(count($emailResults) > 0)
{
echo 'That email is already in use, are you sure you\'re not registered with us already? <a href="loginPage.php">Login Here</a>';
}
else
{
$sql = "INSERT INTO users (Firstname, Lastname, Role, Email, Username, Password) VALUES (:firstname, :lastname, :role, :email, :username, :passwords)";
$stmt = $conn->prepare($sql);
$hashPassword = password_hash($password, PASSWORD_DEFAULT);
$stmt->bindParam(':firstname', strip_tags($firstname));
$stmt->bindParam(':lastname', strip_tags($lastname));
$stmt->bindParam(':role', $_POST['role']);
$stmt->bindParam(':email', strip_tags($email));
$stmt->bindParam(':username',strip_tags($username));
$stmt->bindParam(':passwords',strip_tags($hashPassword));
if ($stmt->execute())
{
echo 'Well done! You have successfully registered with us!';
header('Location:loginPage.php');
}
else
{
echo 'There seems to be an issue getting you registered.';
//$message = 'There seems to be an issue getting you registered.';
}
}
}
}
else
{
echo 'Your passwords do not match, please enter them correctly.';
//$message = 'Your passwords do not match, please enter them correctly.';
//header('Location:registerPage.php');
}
}
else
{
echo 'Your password must be between 6 to 32 characters.';
//header('Location:registerPage.php');
}
}
Database - Table users: (Required by login and register)
CREATE TABLE users
(
id INT(11) PRIMARY KEY NOT NULL AUTO_INCREMENT,
Firstname VARCHAR(50) NOT NULL,
Lastname VARCHAR(50) NOT NULL,
Role VARCHAR(30) NOT NULL,
Email VARCHAR(150) NOT NULL,
Username VARCHAR(60) NOT NULL,
Password VARCHAR(128) NOT NULL
);
CREATE UNIQUE INDEX Email ON users (Email);
CREATE UNIQUE INDEX Username ON users (Username);