AbydosGater Posted December 6, 2006 Share Posted December 6, 2006 Hey people me is back again :P this time with a hard one.. I think anyways :PI am working on a messaging system.. and i am going to have a viewmessage.phpBut 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 https://forums.phpfreaks.com/topic/29685-matching-up-values-with-if-and-or-not-really-working/ Share on other sites More sharing options...
joquius Posted December 6, 2006 Share Posted December 6, 2006 When you have != , make the || an &&Notice that at the moment the person could have sent the message, but only one part of the if has to be negative to get a true result. Link to comment https://forums.phpfreaks.com/topic/29685-matching-up-values-with-if-and-or-not-really-working/#findComment-136232 Share on other sites More sharing options...
AbydosGater Posted December 6, 2006 Author Share Posted December 6, 2006 What will that do? i though that was for and? Link to comment https://forums.phpfreaks.com/topic/29685-matching-up-values-with-if-and-or-not-really-working/#findComment-136233 Share on other sites More sharing options...
joquius Posted December 6, 2006 Share Posted December 6, 2006 It's like "He didn't send AND he didn't receive" whereas at the moment "He didn't send and receive (impossible to negate)" Link to comment https://forums.phpfreaks.com/topic/29685-matching-up-values-with-if-and-or-not-really-working/#findComment-136234 Share on other sites More sharing options...
AbydosGater Posted December 6, 2006 Author Share Posted December 6, 2006 Yes but then what if the person who was sent the message views itThe 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 Link to comment https://forums.phpfreaks.com/topic/29685-matching-up-values-with-if-and-or-not-really-working/#findComment-136239 Share on other sites More sharing options...
joquius Posted December 6, 2006 Share Posted December 6, 2006 Yes yes that's exactley it. When$a != $b && $a != $c ONLY when both statements are true it throws the error (in your case) Link to comment https://forums.phpfreaks.com/topic/29685-matching-up-values-with-if-and-or-not-really-working/#findComment-136240 Share on other sites More sharing options...
AbydosGater Posted December 6, 2006 Author Share Posted December 6, 2006 Well i tryed this and its still throwing that error at me Link to comment https://forums.phpfreaks.com/topic/29685-matching-up-values-with-if-and-or-not-really-working/#findComment-136267 Share on other sites More sharing options...
Psycho Posted December 6, 2006 Share Posted December 6, 2006 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){ Link to comment https://forums.phpfreaks.com/topic/29685-matching-up-values-with-if-and-or-not-really-working/#findComment-136274 Share on other sites More sharing options...
AbydosGater Posted December 6, 2006 Author Share Posted December 6, 2006 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 Link to comment https://forums.phpfreaks.com/topic/29685-matching-up-values-with-if-and-or-not-really-working/#findComment-136294 Share on other sites More sharing options...
Psycho Posted December 6, 2006 Share Posted December 6, 2006 [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 https://forums.phpfreaks.com/topic/29685-matching-up-values-with-if-and-or-not-really-working/#findComment-136344 Share on other sites More sharing options...
AbydosGater Posted December 6, 2006 Author Share Posted December 6, 2006 No because the user could be either the sender OR the reciever, if so they are aloud access, if not go bye bye Link to comment https://forums.phpfreaks.com/topic/29685-matching-up-values-with-if-and-or-not-really-working/#findComment-136478 Share on other sites More sharing options...
kenrbnsn Posted December 6, 2006 Share Posted December 6, 2006 Try this:[code]<?phpif (!($sender_id == $member_id || $sent_to == $member_id))?>[/code]Ken Link to comment https://forums.phpfreaks.com/topic/29685-matching-up-values-with-if-and-or-not-really-working/#findComment-136480 Share on other sites More sharing options...
AbydosGater Posted December 6, 2006 Author Share Posted December 6, 2006 No thats what i have at the moment and its not working...Ehh i have an idea... Take this topic as SOLVED! hehe Link to comment https://forums.phpfreaks.com/topic/29685-matching-up-values-with-if-and-or-not-really-working/#findComment-136481 Share on other sites More sharing options...
kenrbnsn Posted December 6, 2006 Share Posted December 6, 2006 Please post the solution.Ken Link to comment https://forums.phpfreaks.com/topic/29685-matching-up-values-with-if-and-or-not-really-working/#findComment-136482 Share on other sites More sharing options...
Psycho Posted December 7, 2006 Share Posted December 7, 2006 [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 https://forums.phpfreaks.com/topic/29685-matching-up-values-with-if-and-or-not-really-working/#findComment-136550 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.