Mixing PHP and HTML - blank page results ...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
simon-b
Forum Newbie
Posts: 4
Joined: Fri Jun 08, 2007 12:29 am

Mixing PHP and HTML - blank page results ...

Post 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
Last edited by simon-b on Sun Jul 29, 2007 6:04 pm, edited 1 time in total.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Post 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.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

You have 3 exit() statements at the top of your page. I'd look there before anywhere else ;)
simon-b
Forum Newbie
Posts: 4
Joined: Fri Jun 08, 2007 12:29 am

Post 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>
simon-b
Forum Newbie
Posts: 4
Joined: Fri Jun 08, 2007 12:29 am

Post by simon-b »

Thanks Chris. Tried removing them one by one, seems they're either required or redundant (have no effect).


Simon
Last edited by simon-b on Sun Jul 29, 2007 6:05 pm, edited 1 time in total.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Post 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. 8O 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??
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

The only redirect you have in your code is inside this block:

Code: Select all

if ($spit = "true"){
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.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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.
simon-b
Forum Newbie
Posts: 4
Joined: Fri Jun 08, 2007 12:29 am

Post 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.
Post Reply