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

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.