Jump to content

Recommended Posts

What are some possible causes for a PHP page to simply come up as a blank white page? It was working fine, I edited some code, and now it just comes up blank.

 

No errors or partial source or anything.

 

The file is long so I didn't want to post it. Just looking for some possible hints that I could check out myself before asking someone to look at it as a last resort.

Link to comment
https://forums.phpfreaks.com/topic/136111-solved-page-not-loading/
Share on other sites

Error of some type and errors turned off.

 

Try adding this to the top of the code:

 

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);

 

If it was a loop you added, make sure it is not doing an infinite loop.

 

if it's a syntax error, that won't show it though. so if the above doesn't work, try adding an .htaccess file in the directory with the following:

php_value display_errors 1

I think I narrowed it down to a small section. When I take this out, the page loads fine.

 

<?php
if (isset($_POST['Submit']) && $_POST['Submit'] == "Submit")
{
foreach ($_POST as $key => $val)
{
	$_POST[$key] = trim(stripslashes($val));
}

$to = "xxx.xxx@xxx.com"; // send the form here
$concerning = $_POST['concerning'];
$name = $_POST['name'];
$email = $_POST['email'];
$address = $_POST['address'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$phone = $_POST['phone'];
$student_type = $_POST['student_type'];
$major = $_POST['major'];
$information = $_POST['information'];
$captcha = $_POST['captcha'];

$errors .= (empty($concerning))
	? "<br />Please choose what this is concerning."
	: FALSE;
$errors .= (empty($name))
	? "<br />Please fill in your name."
	: "";
$errors .= (empty($email)||!preg_match("/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*(([,]|[,])\s*\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*)*$/", $email))
	? "<br />Please fill in your email address."
	: FALSE;
$errors .= (empty($student_type))
	? "<br />Please choose a student type."
	: FALSE;
$errors .= (empty($captcha)||!(strtolower($captcha=="BUZZ")))
	? "<br />Please type the correct word."
	: FALSE;

if (!$errors)
{
	$msg = "Concerning: {$concerning}\nName: {$name}\nEmail: {$email}\nAddress: {$address}\nCity, State ZIP: {$city, $state $zip}\nPhone: {$phone}\nStudent Type: {$student_type}\nMajor: {$major}\nInformation: {$information}\n";
	$headers .= "From: {$name} <{$email}>\r\n";
	$subject = "The Advisor - Contact Form";

	ini_set(sendmail_from, $email);
	$bool = mail($to, $subject, $msg, $headers);
	ini_restore(sendmail_from);

	if ($bool)
	{
		header("Location: thankyou.php");
		exit;
	} else
	{
		DIE ("Something happened that wasn't supposed to. Please send an email to {$to} and tell me that you got this message.");
	}
}
}
?>

Do some debugging:

 

if (!$errors)
   {
       echo 'here0';
      $msg = "Concerning: {$concerning}\nName: {$name}\nEmail: {$email}\nAddress: {$address}\nCity, State ZIP: {$city, $state $zip}\nPhone: {$phone}\nStudent Type: {$student_type}\nMajor: {$major}\nInformation: {$information}\n";
      $headers .= "From: {$name} <{$email}>\r\n";
      $subject = "The Advisor - Contact Form";
      echo 'here1';
      ini_set(sendmail_from, $email);
      echo 'here2';
      $bool = mail($to, $subject, $msg, $headers);
      echo 'here3';
      ini_restore(sendmail_from);
     echo 'here4';
      if ($bool)
      {
                echo 'here5';
         header("Location: thankyou.php");
         exit;
      } else
      {
      echo 'here6';
         DIE ("Something happened that wasn't supposed to. Please send an email to {$to} and tell me that you got this message.");
      }
   }
}
?>

 

And see where it stops and go from there. Where it stops it means the line below is the culprit

Well theres your answer right there.

 

The page will not load on it's own cause for the first if statement there is no else....try this:

<?php
if (isset($_POST['Submit']) && $_POST['Submit'] == "Submit")
{
   foreach ($_POST as $key => $val)
   {
      $_POST[$key] = trim(stripslashes($val));
   }
   
   $to = "xxx.xxx@xxx.com"; // send the form here
   $concerning = $_POST['concerning'];
   $name = $_POST['name'];
   $email = $_POST['email'];
   $address = $_POST['address'];
   $city = $_POST['city'];
   $state = $_POST['state'];
   $zip = $_POST['zip'];
   $phone = $_POST['phone'];
   $student_type = $_POST['student_type'];
   $major = $_POST['major'];
   $information = $_POST['information'];
   $captcha = $_POST['captcha'];
   
   $errors .= (empty($concerning))
      ? "<br />Please choose what this is concerning."
      : FALSE;
   $errors .= (empty($name))
      ? "<br />Please fill in your name."
      : "";
   $errors .= (empty($email)||!preg_match("/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*(([,]|[,])\s*\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*)*$/", $email))
      ? "<br />Please fill in your email address."
      : FALSE;
   $errors .= (empty($student_type))
      ? "<br />Please choose a student type."
      : FALSE;
   $errors .= (empty($captcha)||!(strtolower($captcha=="BUZZ")))
      ? "<br />Please type the correct word."
      : FALSE;
   
   if (!$errors)
   {
      $msg = "Concerning: {$concerning}\nName: {$name}\nEmail: {$email}\nAddress: {$address}\nCity, State ZIP: {$city, $state $zip}\nPhone: {$phone}\nStudent Type: {$student_type}\nMajor: {$major}\nInformation: {$information}\n";
      $headers .= "From: {$name} <{$email}>\r\n";
      $subject = "The Advisor - Contact Form";
      
      ini_set(sendmail_from, $email);
      $bool = mail($to, $subject, $msg, $headers);
      ini_restore(sendmail_from);
      
      if ($bool)
      {
         header("Location: thankyou.php");
         exit;
      } else
      {
         DIE ("Something happened that wasn't supposed to. Please send an email to {$to} and tell me that you got this message.");
      }
   }
}else {
     DIE("This was not submitted via a form, page is intentionally blank.");
}
?>

I'm pretty sure the HTML code outside the PHP tags will load. If the if statement is skipped over, the HTML should load. I don't need an else.

 

But, to be sure, I added an else statement with an echo inside. Nothing was printed on the screen.

I'm pretty sure the HTML code outside the PHP tags will load. If the if statement is skipped over, the HTML should load. I don't need an else.

 

But, to be sure, I added an else statement with an echo inside. Nothing was printed on the screen.

 

I see. Well it seems you may have some issues with your server, or the file that is including the above file.

 

Since this is being included I would not use the DIE for the else as it would kill the script always if post is not set, but to test the page itself by calling thatpage.php see if that die is printed, if it is than the problem lies on the other page.

 

Can you post the code that includes the above file?

Removing exit didn't work.

 

I've contacted the server admin and he's trying to get home to show me how to [insert something I didn't understand. Forcing to show errors in some way even if the page comes up blank. I think it's a test to determine if the code could possibly run. I have no idea.] But I seriously don't see any syntax errors.

When I delete this one line, the page comes up!

 

<?php
$msg = "Concerning: {$concerning}\nName: {$name}\nEmail: {$email}\nAddress: {$address}\nCity, State ZIP: {$city, $state $zip}\nPhone: {$phone}\nStudent Type: {$student_type}\nMajor: {$major}\nInformation: {$information}\n";
?>

 

Anyone see anything?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.