How do you show an HTML page in php

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
verymeanguy
Forum Newbie
Posts: 6
Joined: Sat Jul 19, 2008 5:40 am

How do you show an HTML page in php

Post by verymeanguy »

I need to know how to show HTML pages in my php code.

Code: Select all

 
if(isset($_SESSION['user'])){
   include('protected.html');
}
else{
   include('login.html');
}
Will this do what I want to do(which I think is fairly obvious)?
User avatar
Apollo
Forum Regular
Posts: 794
Joined: Wed Apr 30, 2008 2:34 am

Re: How do you show an HTML page in php

Post by Apollo »

You're including a .html file directly in PHP. Try readfile("something.html") instead.

By the way, you're only checking if $_SESSION['user'] exists, no verification whatsoever. I don't know how well protected you need protected.html to be, are you sure this is safe? For starters, nothing stops people from directly surfing to yoursite.com/protected.html...
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: How do you show an HTML page in php

Post by RobertGonzalez »

Have you tried it yet? Try it and let us know what happens.
User avatar
Buddy
Forum Newbie
Posts: 9
Joined: Tue Apr 08, 2008 9:28 am

Re: How do you show an HTML page in php

Post by Buddy »

right.

I have tested the function readfile(). it works very well.
Post Reply