Hi everybody, I am learning php and I need some help. I want to hide some text from users who are not logged in. I do this $fullpage = preg_replace("#http://rapidshare.com/(.+?)\ #i", "File is on rapidshare.com! <br />", $fullpage); PHP: Now, How can i not hide this text if user is logged in. I managed to make a loggin script. <? session_start(); if(!session_is_registered(myusername)){ header("location:main_login.php"); } ?> PHP: I think i need to use if statement but i do not know how to. Thanks
Start using if (isset($_SESSION['sessionname'])) { stuff you want only logged in people to see.... } else { echo "You must be logged in to see this content"; } PHP: session_is_registered is getting deprecated in the next version of PHP. Start updating your code now.
Assuming that you are setting the myusername session variable, you would want to do this. session_start(); if(!$_SESSION['myusername']){ header("location:main_login.php"); } PHP:
thank you all. it worked <? if (isset($_SESSION['myusername'])) { ?> <?= stripslashes ($full)?> <? } else { ?> <?= stripslashes ($fullpage)?> <? } ?> PHP: How can i tidy up this code? thanks
<? if (isset($_SESSION['myusername'])) { ?> echo stripslashes($full); } else { echo stripslashes($fullpage); } ?> PHP: