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 远程桌面文档内容复制粘贴,格式会变化
  • ¥15 关于#java#的问题:找一份能快速看完mooc视频的代码
  • ¥15 这种微信登录授权 谁可以做啊
  • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄
  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题