Jump to content

What's wrong with my if not equal statement?


Go to solution Solved by Psycho,

Recommended Posts

It seemed to be working at some point but I'm not sure what I did now it displays the Admin Page button forever, I don't want it to include the button if the user admin is on the page.

 

On the top of the admin.php page after the session_start(); I have this:

$_SESSION['url']="http://www.golden-wand.com/pages/admin.php";

In the header.php I have this:

<?php if($_SESSION['admin']==='1'){
	if($_SESSION['url'] != 'http://www.golden-wand.com/Pages/admin.php'){ ?>
	<input type="button" value="Admin Page" class="button hvr-wobble-skew" onclick="location.href='http://www.golden-wand.com/Pages/admin.php'">
<?php }} ?>

It's seems to be skipping the second if statement, I'm probably doing something wrong.  I originally was attempting to put the entire input Admin Page button into a variable to be echoed back in my message section but it never worked because the variable seems to mess up the onclick fucntion since it's unable to accept double quotes.  Please let me know how to accomplish hiding the button if this page exists :)  Thanks

 

 

I need this here with every post right?  I own this site:  http://www.golden-wand.com/phpfreaks.txt    just added it to my signature :)

Edited by PineSmokes
  • Solution

You only need to include a link to a txt file if you are wanting us to run some specific tests on your site. You do not need it to ask a question about some code.

 

You may have a failure on both conditions:

 

if($_SESSION['admin']==='1'){

 

The three equal signs means it has to match the value and the type - i.e. it has to be a string value of one. A numeric value of 1 will not pass the condition.

 

On the second condition it will never match because "pages" does not equal "Pages"

Actually the first condition does work perfectly fine and you nailed the second one right on the head, that one seems to work fine but it is nice to know what two and three equal signs mean so thanks for that :)

 

You only need to include a link to a txt file if you are wanting us to run some specific tests on your site. You do not need it to ask a question about some code.

 

You may have a failure on both conditions:

if($_SESSION['admin']==='1'){

The three equal signs means it has to match the value and the type - i.e. it has to be a string value of one. A numeric value of 1 will not pass the condition.

 

On the second condition it will never match because "pages" does not equal "Pages"

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.