Page 1 of 1
Mixing PHP and HTML - blank page results ...
Posted: Fri Jun 08, 2007 1:05 am
by simon-b
I've made a site with a script which forces users to tick an "accept" box before getting access to a new page. The "spit back" works fine, but when the user fulfils the criteria (ticks the box) the page they're directed to appears blank. It's not blank - I know this, because I can see it in GoLive!
Code for the resulting "blank" page is below.
Anyone?
Thanks
Simon
Posted: Fri Jun 08, 2007 1:19 am
by califdon
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">";
Looks like you've got embedded double quotes there.
In general, a blank page is usually caused by a syntax error in the PHP, causing the web server to gag and send nothing beyond any HTML that precedes the first PHP block containing the error. You can check this by viewing the source page.
Posted: Fri Jun 08, 2007 1:29 am
by Chris Corbyn
You have 3 exit() statements at the top of your page. I'd look there before anywhere else

Posted: Fri Jun 08, 2007 1:31 am
by simon-b
Thanks Califdon
The source code showing on the blank page in the browser is as below. Can you suggest a fix for a code-challenged PHP newbie ... ??
Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1"></HEAD>
<BODY></BODY></HTML>
Posted: Fri Jun 08, 2007 3:05 am
by simon-b
Thanks Chris. Tried removing them one by one, seems they're either required or redundant (have no effect).
Simon
Posted: Fri Jun 08, 2007 1:07 pm
by califdon
simon-b wrote:Thanks Califdon
The source code showing on the blank page in the browser is as below. Can you suggest a fix for a code-challenged PHP newbie ... ??
Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1"></HEAD>
<BODY></BODY></HTML>
That is very odd. As you can see from your own HTML, that doesn't seem to be coming from the file you showed us. You showed us a file with several META tags and several arguments in the BODY tag, in plain HTML, which do not appear in the page source. As far as I can see, there's no way that page could have been generated from the file you showed us, regardless of PHP.
Sorry, I'm still mystified by the Aussie talk, but that's okay.

And I don't understand what you meant about the DOCTYPE line. As it was in the original code you posted, there are several double quotes within the
echo statement, which would not be parsed correctly by PHP. In your more recent code posting, it is located completely differently, outside the PHP tags, as you pointed out. What's going on??
Posted: Fri Jun 08, 2007 3:40 pm
by RobertGonzalez
The only redirect you have in your code is inside this block:
Which is assigning not evaluating. Also, based on that mash of totally non-compliant markup, I would guess that goLive will show you just about anything even it is broken. Blank pages are usually a sign of a parse error, so I would check your error logs as well. Also, as per the HTTP spec, header redirects should be to full URI's not relative ones like you are using.
Posted: Fri Jun 08, 2007 3:44 pm
by RobertGonzalez
Couple of other things...
Your checkbox check is looking for checked (which is a javascript value). PHP uses 'on'. Generally doing !empty() on a checkbox will tell you if it is checked or not.
Also, you are extracting from $HTTP_POST_VARS. Long superglobal arrays are deprecated. You should be using $_POST instead.
Posted: Sat Jun 09, 2007 9:58 pm
by simon-b
Yes, sorry Califdon, the first lot of mashed-up non-compliant code I posted was from an old file - not the one on the server. My mistake. Sloppy. I put you crook! (meaning, "I misled you" in Aussie- and Kiwi-speak)
Everah, many thanks for you help.