Jump to content

If statement


3raser

Recommended Posts

I've never really had this problem before. I'm trying to make it so only moderators can edit titles.

 

This is currently my if statement:

 

elseif($type == 2 && acc_status(getUsername()) > 1 && !isset($_POST['title']) || !isset($_POST['content']))

 

(I can assure you getUsername() works)

 

Interpretation: If the editing type is 2 (thread/topic) and the user's account status is higher than 2 (meaning admin & mod) and the title or message/content isn't set, display the content within the if statement block. Why is it users with a user status of 1 can see the information within the block statement, allowing them to see the "edit title" field?

Link to comment
Share on other sites

Because you're essentially saying "if this and this, OR this". See if this fixes it:

elseif(($type == 2 && acc_status(getUsername()) > 1) && (!isset($_POST['title']) || !isset($_POST['content'])))

 

This is saying "if this and this, AND this or this".

Link to comment
Share on other sites

Because you're essentially saying "if this and this, OR this". See if this fixes it:

elseif(($type == 2 && acc_status(getUsername()) > 1) && (!isset($_POST['title']) || !isset($_POST['content'])))

 

This is saying "if this and this, AND this or this".

 

Thank you. I completely forgot about the use of nested if statements within an actual if statement. I'm sure there is a proper term for them, but I just can't seem to remember.

 

Once again, thanks.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.