Ghezzo Posted November 25, 2009 Share Posted November 25, 2009 Hey, what is the easiest way to show certain links for logged in users, and other links for non-logged in users? Like I want to show "Register" and "Login" for non-logged in users and "Members Area" and "Logout" for logged in users. Is there some easy way to do this? And one more thing, a guy told me my site was vulnerable to SQL injections. He said: "Your code is vulnerable for sql injections. You' should pass all your post data through a function like mysql_real_escape()." How do I fix this? I'm very new to PHP. Quote Link to comment https://forums.phpfreaks.com/topic/182919-show-links-for-logged-in-users/ Share on other sites More sharing options...
sKunKbad Posted November 25, 2009 Share Posted November 25, 2009 mysql_real_escape_string is a php function, and you can read about using it in the php manual: http://us.php.net/manual/en/function.mysql-real-escape-string.php As for checking if a user is logged in, what are you using to log them in? Once logged in, are you setting a cookie with some sort of value? This is what you would check. Quote Link to comment https://forums.phpfreaks.com/topic/182919-show-links-for-logged-in-users/#findComment-965493 Share on other sites More sharing options...
Ghezzo Posted November 25, 2009 Author Share Posted November 25, 2009 As I said, I'm very new to PHP But I pretty sure it's cookies. Quote Link to comment https://forums.phpfreaks.com/topic/182919-show-links-for-logged-in-users/#findComment-965536 Share on other sites More sharing options...
Ghezzo Posted November 25, 2009 Author Share Posted November 25, 2009 Got it working with this code <?php if(isset($_COOKIE['ID_my_site'])) echo '<a href="members.php">Members Area</a> | <a href="logout.php">Logout</a> | You are logged in as: (Coming soon)'; else echo '<a href="register.php">Register</a> | <a href="login.php">Login</a> | You are not logged in.</a>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/182919-show-links-for-logged-in-users/#findComment-965555 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.