0

请有人帮忙。当用户通过注册表或登录表单发送详细信息时,如果详细信息有效,则可以正常工作,但如果无效。错误显示在白页上.. 白页不是空的,而是显示我设置的错误.. 它重定向到我的 URL.. 除了错误之外不显示任何其他内容.. 请无论如何去做吧.. 我检查了我的 Apache 日志文件中的错误日志。那里没有错误报告..我超级困惑

我也尝试过使用

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

还是什么都没有显示。。

尝试通过更改使用破解它

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

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

它只是简单地显示与我的错误相同的 WSOD 并按预期重定向,但我希望在页面加载之后而不是之前显示错误。这对我来说是不可能的。

请有人帮助我..真的很沮丧

附言

$comeFrom = $_SERVER['HTTP_REFERER'];

仍然试图重定向到索引页面..同样的问题..

这是我的 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 } ?>

我上面代码中的头文件包含这个

<?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");
}
?>

我的 log_reg 包含更像是一个 pop_up 登录文件,它包含在所有页面上,提交时需要下面的 register.inc.php 文件

这是我的 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);
?>

因此,在成功完成后,它会使用我的 smtp4dev 向我发送一封电子邮件。但是如果出现错误。转到白页并仅显示错误而没有其他 html 内容。

如果代码混乱,堆栈溢出是新的,我深表歉意。提前致谢

4

1 回答 1

0

谢谢,我已经把它整理出来了,它没有报告任何错误,因为实际上没有报告错误。我只是将 log_reg 文件放在我的代码之前,由于 Die() 调用,它正在杀死后面的其他输出。 .我只将include(“log_reg”)文件放到页面底部并对其进行了排序..以防万一有人遇到类似的事情..

于 2018-01-10T12:22:21.363 回答