Jump to content

Recommended Posts

Hi Guys,

 

what i'm trying to do here is make the "message me" button dissapear IF the logged in users is viewing theyre own profile (basically so people can't message them self)

 

hers the code i have:

 

           <td width="200" align="right">About Me</td><td align="left">'.$about_me.'</td>
           </tr>
           <tr>
           <td width="200" align="right">Actions</td><td align="center">(<a href="add_friend.php?id='.$id.'">Add To Friends</a>)</td>
           </tr>
           <tr>
           <td colspan="2" align="center">';
           // make a query to see if the logged in user has access to the message me button.../
           $query4 ="SELECT * FROM `membership` WHERE `id`='$id'";
           $result4 = mysql_query($query4) or die (mysql_error());
           $rows = mysql_fetch_array($result4) or die (mysql_error());
           
           //$row_to_match = $rows['id'];
           
           if(mysql_num_rows($result4)) {
           
              echo '<input type="submit" name="submit" value="Send Message To '.$username.'" />';
           
           } else {
           
              echo "";
           
           }           
           
           //<input type="submit" name="submit" value="Send Message To '.$username.'" />
           
   echo '  <input type="hidden" value="'.$id.'" />
           </td>
           </tr>
           </table></form><br />';

 

can nayone point me in the right direction on what i'm doing wrong?

 

cheers guys

 

Graham

Link to comment
https://forums.phpfreaks.com/topic/52051-solved-querying-database-for-info/
Share on other sites

Why not just make it so when they send the message it checks if they sent it to themselves. You would obviously have the persons ID they are trying to message, so you can do a check agains the ID's with that info.

 

<?php

//the person they are trying to message, ID is coming from the message form they filled out
$id = $_POST['id'];

//Now check that ID against their ID
if ($id == $user_id){
   echo "You can't message yourself!";
exit;

} else {

   //go on with allowing them to message the person
}

?>

 

I am assuming you have their ID stored in a session, and that is where I pulled the "$user_id" variable from.

 

 

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.