Im trying to avoid putting my login code on every page that needs authentication.
Is it possible to do something like have an include with an if statement which is left open so the rest of the page can exist inside my open else{, then at the end i will include a foot that just contains the } closing tag for the if?
heres my include
So my page looks like:Code:<? //check login if(!$logged_in){ echo("<p><strong>Error</strong><br />You need to be logged in to access this page. Click <a href='login.php'>here</a> to login</p>"); }else{ ?>
But it throws an error saying unexpected $end in the include.Code:<html> blah blah <h1>Welcome</h1> <? include("..assets/login_check_head.php"); ?> THIS IS THE PROTECTED PAGE CONTENTS <? include"..assets/login_check_foot.php ?> blah blah </html>
Any ideas? Or I will have to just insert this code into every page that requires login.
Cheers




Reply With Quote