donglu5047 2016-04-11 20:27
浏览 89
已采纳

从Linux迁移到Windows后的WSOD

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);
  • 写回答

1条回答 默认 最新

  • duankaolei2921 2016-04-11 20:50
    关注

    You are using PhpStorm's own built-in web server, which has some issues right now (especially with POST requests, e.g. WEB-17317 -- you can watch this ticket (star/vote/comment) to get notified on any progress).

    The solution is to use your own proper web server (Apache from your XAMPP).

    1. Define Deployment entry of appropriate type. In place type could be fine, as long as your Apache can serve files from that location; otherwise either configure web server to be able to do that .. or use another type of deployment (e.g. Local or Mounted Folders for IDE to copy files to another location for you).
    2. Configure it (provide desired URL etc) -- make sure it shows no warnings about unfilled fields on first 2 tabs.
    3. Mark it as Default for this project.

    Now IDE will use that base URL when you will use Open in Browser or Run/Debug actions (NOTE: it will not affect any existing Run/Debug Configurations -- only future ones; you will have to update your current Run/Debug Configurations manually).


    What's the difference between the two: https://stackoverflow.com/a/33598214/783119

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 netty整合springboot之后自动重连失效
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击