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
Yes but then what if the person who was sent the message views it
The if would fail because $sender_id != $member_id , so it would meta refresh the inbox..

I need it to be so that both the sender and reciptant can view the message but no other member_ids
If I am understanding you correctly, you want the "Meta Refresh The Inbox2" to be displayed if the user is the sender or if the user is the receiver. Then you if statement should be:

if ($sender_id == $member_id || $sent_to == $member_id){
[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.
[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.

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.