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 Quote Link to comment 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. Quote Link to comment 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? Quote Link to comment 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)" Quote Link to comment 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 Quote Link to comment 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) Quote Link to comment 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 Quote Link to comment 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){ Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted December 6, 2006 Share Posted December 6, 2006 Please post the solution.Ken Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.