简体   繁体   English

在Wsod上显示错误,但在成功重定向后无法显示内容

[英]Error Displaying On Wsod Yet Failing To Display Contents After Successful Redirect

Please can someone help. 请有人帮忙。 When users send details through registration form or signin form, if details are valid, it works fine, but if it invalid. 当用户通过注册表格或登录表格发送详细信息时,如果详细信息有效,则可以正常工作,但无效。 The errors displays on a white page.. The white page is not empty, but displays the error I set.. It redirects to my URL.. Just doesn't show any other content apart from the error.. Please is there anyway to go about it.. I checked the error log in my Apache log files. 错误显示在白页上。白页不是空白,而是显示我设置的错误。它重定向到我的URL。只是不显示除错误以外的任何其他内容。继续解决。.我检查了Apache日志文件中的错误日志。 There's no error reporting there.. I'm super confused 那里没有错误报告。.我很困惑

I have also tried using 我也尝试使用

error_reporting(E_ALL);
ini_set("display_errors", TRUE); 
ini_set("display_startup_errors",TRUE); 
ini_set("html_errors",0);

Still nothing is showing.. 仍然没有任何显示。

Tried using a hack around it by changing 尝试通过更改来解决问题

header("Location: $comeFrom");
echo "MY ERROR HERE"
die; 

To

header("refresh:0; url=$comeFrom");
echo "MY ERROR HERE"
die; 

which simply shows the same WSOD with my error briefly and redirects as supposed, but I want the error to show after the page loads not before. 它只是简单地显示与我的错误相同的WSOD并按预期方式重定向,但是我希望错误在页面加载之后而不是之前显示。 Which is impossible for me. 这对我来说是不可能的。

Please someone help me.. Really frustrated 请有人帮我..真的很沮丧

PS 聚苯乙烯

$comeFrom = $_SERVER['HTTP_REFERER'];

Still tried to redirect to the index page.. Same issue.. 仍然尝试重定向到索引页面。

This is my search.php file 这是我的search.php文件

<?php
session_start();
include_once('db.php');
if(!isset($_GET['page']) or $_GET['page']==0 or !preg_match("/^[1-9]*$/", $_GET['page'])){
header("Location: search.php?q=$_GET[q]&page=1");
}else{
$page = $_GET['page'];
}

if (isset($_GET['q']) and !empty($_GET['q'])){
$search=stripslashes(mysqli_real_escape_string($conn,$_GET["q"]));
$do="INSERT INTO search_terms".
"(terms)".
"VALUES".
"('$search')";
mysqli_query ($conn,$do);

}else{
header ("Location: index.php");
}
$pagetitle = "Search";
include_once('includes/header.php');
include_once('includes/log_reg.php');

?>

<body>

<div class="search_body">
<button id="goback" onclick="back()" type="button">Go back</button>
<button id="goforward" onclick="forward()" type="button">Go Forward</button>
<div class="tab">
<button class="tablinks" id="defaultOpen" onclick="openTab(event,'Products')">Properties</button>
<button class="tablinks" onclick="openTab(event, 'Forum')">Forum</button>
<button class="tablinks" onclick="openTab(event, 'Users')">Users</button>
</div>

<div id="Products" class="tabcontents">
<?php
include_once('db.php');
$per_page=6;
$start = (($page - 1) * $per_page);
$sql="SELECT * FROM table LIKE '%$search%'";
$pages_query=mysqli_query($conn,$sql) or die("Bad Query: $sql");
$number = mysqli_num_rows($pages_query);
$number = number_format($number);
ceil($pages = $number/$per_page); 

$sql2="SELECT * FROM table LIMIT $start,$per_page";
$result = mysqli_query ($conn,$sql2);
if ($number == 0) {
echo " ";}else{
   if($page > 1){
      echo "<a class='pagination' href=search.php?q=$_GET[q]&page=1>FIRST</a>";
      if ($page > 2){
      echo "<a class='pagination' href=search.php?q=$_GET[q]&page=". ($page - 2).">&#8810;</a>";
      }
      echo "<a class='pagination' href=search.php?q=$_GET[q]&page=".($page - 1).">&lt;</a>";
  }
 }
 $skipped = false;

 for ($i = 1; $i <= $pages + 1; $i++) {
 if ($page == $i){
     echo "<a class='actived' href=search.php?q=$_GET[q]&page=".$i.">".$i."</a>";
 }else{
     if ($i < 1 || ($pages) - $i < 1 || abs($page - $i) < 2) {
         if($skipped)
             echo '<span> ... </span>';
         $skipped = false;
echo "<a class='pagination' href=search.php?q=$_GET[q]&page=".$i.">".$i."</a>";
}else{
$skipped = true;
} 
}
}
if ($number == 0) {
echo "";
}else{
if($page < $pages){
      echo "<a class='pagination' href=search.php?q=$_GET[q]&page=".($page + 1).">&gt;</a>";
      if ($page < ($pages - 1)){
      echo "<a class='pagination' href=search.php?q=$_GET[q]&page=".($page + 2).">&#8811;</a>";
      }
      echo "<a class='pagination' href=search.php?q=$_GET[q]&page=".ceil($pages).">LAST</a>";
  }
if ($page == 1){
 if ($number < $per_page ) {
 echo "<br> Current page: $page <small>(Showing 1-$number of $number results)</small>";
 }else{
 echo "<br> Current page: $page <small>(Showing 1-$per_page of $number results)</small>";
 }}elseif ($page > 1){
if ($page == ceil($pages)) {
     if ($number % 2 == 1){
         if($page = $pages){
             $cal = $number % $per_page;
             $cal2 = ($number - $cal) + 1;
             echo "<br> Current page: ". ceil($page). " <small>(Showing result ".$cal2. "-".($number)."  of $number)</small>";
         }else{
  echo "<br> Current page: $page <small>(Showing ".($start + 1)."-".($start + ($per_page - 1)) ." of $number)</small>";
     }}elseif ($number % 2 == 0 and $page=$pages){
             $cal = $number % $start;
             $cal2 = ($number - $cal) + 1;
             echo "<br> Current page: ".ceil($page)." <small>(Showing result ".$cal2. "-".($number)."  of $number)</small>";
             }elseif ($number % 2 == 0){
    echo "<br> Current page: $page <small>(Showing ".($start + 1)."-". ($start + ($per_page)) ." of $number)</small>";   
     }
}else{
    echo "<br> Current page: $page <small>(Showing ".($start + 1)."-".($start + $per_page) ." of $number)</small>"; 
}
}
}

if ($number>0){
    echo "<p id='search'>" .$number. " results found for '$search' in </p>";
}       else{
    echo "<p id='search'>" .$number. " results found for '$search'. Try a   different search term </p>";
}
echo "<h3>tab 1</h3>";
echo "<div class='my_results'>"
?>
<?php
            while($row=mysqli_fetch_assoc($result)){
                $calc = round(3/2.7, 1);
?>

 <div class="results">
 //results here
 </div>
<?php } ?>

my header include file from above code contains this 我上面代码中的标头包含文件包含此

<?php 
$root= $_SERVER['DOCUMENT_ROOT'];
include($root."/db.php");
$prefix = 'http://'.$_SERVER['SERVER_NAME'].'/';
error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
ini_set('html_errors', 0);  
if (isset($_POST['login'])){
require_once($root."/Hostels/login.inc.php");
}if (isset($_POST['register'])){
    require_once($root."/Hostels/register.inc.php");
}
?>

And my log_reg include is more like a pop_up login file which was included on all pages and on submision requires the register.inc.php file below 而且我的log_reg include更像是一个pop_up登录文件,该文件已包含在所有页面中,并且在submision中需要下面的register.inc.php文件

This is my register.inc.php FILE 这是我的register.inc.php文件

<?php
include('db.php');
$comeFrom = $_SERVER['HTTP_REFERER'];

//session variables to be diaplayed on the profile
if ($_SERVER["REQUEST_METHOD"]==="POST"){
$_SESSION['username']=$_POST['username'];
$_SESSION['firstname']=$_POST['firstname'];
$_SESSION['lastname']=$_POST['lastname'];
$_SESSION['email']=$_POST['email'];
$_SESSION['gender']=$_POST['gender'];
$_SESSION['state']=$_POST['state'];
$_SESSION['dob']=$_POST['dob'];
$user['user_id']=@$_SESSION['user_id'];

//escaping the strings

$username=mysqli_real_escape_string($conn,$_POST['username']);
$firstname=mysqli_real_escape_string($conn,$_POST['firstname']);
$lastname=mysqli_real_escape_string($conn,$_POST['lastname']);
$email=mysqli_real_escape_string($conn,$_POST['email']);
$gender=mysqli_real_escape_string($conn,$_POST['gender']);
$state=mysqli_real_escape_string($conn,$_POST['state']);
$dob=mysqli_real_escape_string($conn,$_POST['dob']);
$password=mysqli_real_escape_string($conn,password_hash($_POST['password'],PASSWORD_BCRYPT));
$hash=mysqli_real_escape_string($conn,md5(uniqid(rand())));
$result=mysqli_query($conn,"SELECT * FROM users WHERE email='$email' OR   username='$username'");
if (strlen($username)<3) { 
header ("Locaton: $comeFrom", true); 
?>
<div id='error1' class= "alert alert-danger"  style="position:absolute;z-index:1000;top:30px;left:50%;"><?php echo    "Username should be atleast 3 characters";?><span class="closeerror"   onclick="document.getElementById('error1').style.display='none'">&times;  </span></div>
<?php
die;
}elseif (strlen($firstname)<3) {
header ("Locaton: $comeFrom", true); 
?>
<div id='error2' class= "alert alert-danger" style="position:absolute;z-index:1000;top:30px;left:50%;"><?php echo "Firstname should be atleast 3 characters";?><span class="closeerror" onclick="document.getElementById('error2').style.display='none'">&times;</span></div>
<?php
die;
}elseif (strlen($lastname)<3) { 
header ("Locaton: $comeFrom", true); ; 
?>
<div id='error3' class= "alert alert-danger" style="position:absolute;z-index:1000;top:30px;left:50%;"><?php echo "Lastname should be atleast 3 characters";?><span class="closeerror" onclick="document.getElementById('error3').style.display='none'">&times;</span></div>
<?php
die;
}elseif(strlen($_POST["password"])<8) { 
header ("Locaton: $comeFrom", true);  
?>
<div id='error4' class= "alert alert-danger" style="position:absolute;z-index:1000;top:30px;left:50%;"><?php echo "Password must be atleast eight characters long";?><span class="closeerror" onclick="document.getElementById('error4').style.display='none'">&times;</span></div>
<?php
die;
}elseif($_POST["password"] != $_POST["confirm_password"]) { 
header ("Locaton: $comeFrom", true);  
?>
<div id='error5' class= "alert alert-danger" style="position:absolute;z-index:1000;top:30px;left:50%;"><?php echo "Password in both fields do not match, please try again.";?><span class="closeerror" onclick="document.getElementById('error5').style.display='none'">&times;</span></div>
<?php
die;
}
if(mysqli_num_rows($result)>0){ 
header ("Locaton: $comeFrom", true); 
?>
<div id='error6' class= "alert alert-danger" style="position:absolute;z-index:1000;top:3%;left:50%;"><?php echo "Email or username is already in use, please enter another";?><span class="closeerror" onclick="document.getElementById('error6').style.display='none'">&times;</span></div>
<?php
die;
}else{//does not exist so we proceed and add user to database
$sql="INSERT INTO users".
"(username,firstname,lastname,email,gender,state,dob,password,hash)".
"VALUES".
"('$username','$firstname','$lastname','$email','$gender','$state','$dob','$p assword','$hash');";
mysqli_query($conn,$sql);

$sql2="SELECT * FROM users WHERE username='$username' AND   firstname='$firstname'";
$result=mysqli_query($conn,$sql2);
if(mysqli_num_rows($result)>0){
while($user=mysqli_fetch_assoc($result)){
$user_id=$user["user_id"];
$sqlimg="INSERT INTO profile_img".
"(user_id)".
"VALUES".
"('$user_id');";
mysqli_query($conn,$sqlimg);
}
}else{
$_SESSION["error"]="Error signing up, please try again or contact us to rectify";
}

$_SESSION["active"]=0;
$user['user_id']=@$_SESSION['user_id'];
//know when the user is logged in
$_SESSION["logged_in"]=false; 
if($_SESSION["logged_in"]=false){
$sqli="SELECT * FROM user WHERE email='$email' and username='$username'";
$result=mysqli_query($conn,$sqli);
while($user=mysqli_fetch_assoc($result)){
    $user['user_id']=$_SESSION["user_id"];
}
}
$_SESSION["message"]=

    "Confirmation message has been sent to your email, please click on the link for full account activation";

    $to=$email;
    $subject="Account Verification";
    $message_body='
    <html>
<head>
<title>Mail Confirmation</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<style>

</style>
</head>
<body>
<span class="name">Hello <span class="user">'.$username.',</span> <br></span><br>
    <div class="message">
    Thank you for signing up with us, we will do our best to provide you with an awesome experience.<br>

    However, your account needs to be fully active, click on the button below to activate your account:<br><br>

    <a class="btn-new" href="http://localhost/login-system /verify.php?email='.$email. '&hash='.$hash. '">Verify Me</a>
</div>
</body></html>';
$headers[] = 'MIME-Version: 1.0';
$headers[] = 'Content-type: text/html; charset=UTF-8';

// Additional headers
$headers[] = 'From:';
$headers[] = 'Cc: Makzino@example.com';
$headers[] = 'Bcc: Makz@example.com';

// Mail it
mail($to, $subject, $message_body, implode("\r\n", $headers));
$_SESSION['success']="Hello $username!!! Registration was successful,   please proceed to login. Thank you";

}}else{
$_SESSION["error"]="Registration failed";
}

mysqli_close($conn);
?>

So on successful completion it sends me an email using my smtp4dev. 因此,成功完成后,它将使用我的smtp4dev向我发送电子邮件。 But if an error occurs. 但是如果发生错误。 Goes to the white page and displays just the error with no other html content. 转到白页,仅显示错误,没有其他html内容。

I apologize if the codes are messy, new to stack overflow. 如果代码太乱了,我很抱歉,这是堆栈溢出的新问题。 Thanks in advance 提前致谢

谢谢,我已经解决了这个问题,它没有报告任何错误,因为实际上没有错误要报告。.我只是将log_reg文件放在我的代码之前,由于Die()调用,它杀死了随后的其他输出。我只将include(“ log_reg”)文件放到页面底部,并对它进行了排序。以防万一有人碰到类似的东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM