Page 1 of 1

How do you show an HTML page in php

Posted: Mon Jul 21, 2008 6:03 am
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)?

Re: How do you show an HTML page in php

Posted: Mon Jul 21, 2008 7:21 am
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...

Re: How do you show an HTML page in php

Posted: Mon Jul 21, 2008 12:52 pm
by RobertGonzalez
Have you tried it yet? Try it and let us know what happens.

Re: How do you show an HTML page in php

Posted: Mon Jul 21, 2008 8:54 pm
by Buddy
right.

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