Pavlos1316 Posted May 28, 2008 Share Posted May 28, 2008 Hello My code below is written so when somebody tries to skip login page and copy/paste the members page url. to show the msg and redirect to login page. Everything is working exept that it prints not only the msg but the 3 last lines of the code as well. (EOF; } ?>) I tried many things but nothing. Any suggestions? ??? <?php //members page session_start(); if(empty($Username)){ print<<<EOF <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="refresh" content="0;url=/"> </head> <body> <center><h1>Unauthorized Access!</h1></center> <center><h1>Please Register... It is Totally Free!!!</h1></center> </body> </html> EOF; } ?> [/quote] Link to comment https://forums.phpfreaks.com/topic/107626-php-code-correction-any-help/ Share on other sites More sharing options...
rhodesa Posted May 28, 2008 Share Posted May 28, 2008 It's much easier to stop/start PHP: <?php //members page session_start(); if(empty($Username)){ //Unauthorized page ?> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="refresh" content="0;url=/"> </head> <body> <center><h1>Unauthorized Access!</h1></center> <center><h1>Please Register... It is Totally Free!!!</h1></center> </body> </html> <?php exit; } ?> Link to comment https://forums.phpfreaks.com/topic/107626-php-code-correction-any-help/#findComment-551657 Share on other sites More sharing options...
Pavlos1316 Posted May 28, 2008 Author Share Posted May 28, 2008 My friend... Thanks a lot. It works fine!!! Link to comment https://forums.phpfreaks.com/topic/107626-php-code-correction-any-help/#findComment-551665 Share on other sites More sharing options...
Pavlos1316 Posted May 28, 2008 Author Share Posted May 28, 2008 More problems... The above works fine. But I have restricted links as well. If I use the same code there too I get unauthorized access etc.. Must I use another code or am I missing something else? Thank you Link to comment https://forums.phpfreaks.com/topic/107626-php-code-correction-any-help/#findComment-551678 Share on other sites More sharing options...
corbin Posted May 28, 2008 Share Posted May 28, 2008 $Username is never set..... Perhaps try changing it to the session variable you are storing the login flag in? Link to comment https://forums.phpfreaks.com/topic/107626-php-code-correction-any-help/#findComment-551696 Share on other sites More sharing options...
Pavlos1316 Posted May 28, 2008 Author Share Posted May 28, 2008 ??? Ok. My mistake I didn't mention I am new at coding. Last month I did a lot of job in my page. But this is maybe my biggest promblem cause everybody saying that I have just to copy paste the same code to my restricted pages. Can you give me an example of what you are saying??? Thanks Link to comment https://forums.phpfreaks.com/topic/107626-php-code-correction-any-help/#findComment-551714 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.