Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/182919-show-links-for-logged-in-users/
Share on other sites

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.

 

 

Got it working with this code :D

 

<?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>';
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.