Jump to content

Recommended Posts

Hey im trying to make a bit of script that will hide links from users that arent logged in.

 

<?php
if(!$_SESSION["loginsuccessfull"]) {
echo '<h2><a href="order.php">Proceed to Order Page</a></h2>
<h2><a href="products.php">Continue Shopping</a></h2>
<h2><a href="resetcart.php">New Cart</a></h2>
<h2><a href="ordertest.php">Proceed to Order Page session</a></h2>';
} else {
echo '
<h2><a href="login.php">Login to view Order Page</a></h2>
<h2><a href="products.php">Continue Shopping</a></h2>
<h2><a href="resetcart.php">New Cart</a></h2>
';
}
?>

 

but even if i have logged in it still only displays

Login to view Order Page

Continue Shopping

New Cart

Link to comment
https://forums.phpfreaks.com/topic/177184-solved-help-hiding-links/
Share on other sites

Looking at your code you have...

 

if(!$_SESSION["loginsuccessfull"]) {

 

Assumably loginsuccessfull is a value that you set when the user has successfully logged in. As you have the exclamation mark, it is a check for a user that isn't logged in. That being the case then the items displayed to logged in users will be the ones in the else block. So why does the word login appear in the else block?

 

Also, a quick tip. If you place...

 

echo '<pre>';
print_r($_SESSION);
echo '</pre>';

 

... at the top of your page, you'll be able to see what session variables you are working with.

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.