Jump to content

Matching Up Values With IF and ||(or) ?? Not really working


AbydosGater

Recommended Posts

Hey people me is back again :P this time with a hard one.. I think anyways :P

I am working on a messaging system.. and i am going to have a viewmessage.php
But i dont want people to be able to just view any message since i am using GET for the message id...
[code]
$msgid = $_GET['id'];
$member_id = $_SESSION['user']['member_id'];
$msgq = mysql_query("SELECT * FROM sf_messages WHERE message_id='$msgid'");
$msg = mysql_fetch_array($msgq);
$sender_id = $msg['sender_id'];
$sent_to = $msg['sent_id'];
if ($sender_id != $member_id || $sent_to != $member_id){
echo "Meta Refresh The Inbox2";
exit();
}
[/code]

The main bit is the last IF to see if the user is either the sender or the reciever (Sent_to) of the message, but its dieing when the user is one of them?
Anyone know why? Thanks
Link to comment
Share on other sites

[quote author=AbydosGater link=topic=117598.msg479903#msg479903 date=1165429973]
Ehh, Not exactly, quite the opposite.. If the user is Not the sender, or the user is Not the reciever then show the meta refresh[/quote]
Then your original conditional should use AND. Otherwise both conditions must mass and the user must be both the submitter and reciever.
Link to comment
Share on other sites

[quote author=AbydosGater link=topic=117598.msg480089#msg480089 date=1165442838]
No because the user could be either the sender OR the reciever, if so they are aloud access, if not go bye bye[/quote]

Um, yes. In this you stated that the condition should pass if the user should not have access to the data
[code]if ($sender_id != $member_id || $sent_to != $member_id){
    echo "Meta Refresh The Inbox2";
    exit();
}[/code]

How that is read is If this member is not the sender OR if the sender is not the recipient. So, that condition will ONLY fail (i.e. user, can view the data) if the member is both the sender or the recipient.
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.