graham23s Posted May 18, 2007 Share Posted May 18, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/52051-solved-querying-database-for-info/ Share on other sites More sharing options...
pocobueno1388 Posted May 18, 2007 Share Posted May 18, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/52051-solved-querying-database-for-info/#findComment-256611 Share on other sites More sharing options...
graham23s Posted May 18, 2007 Author Share Posted May 18, 2007 I never even thought of that , thanks mate:) Graham Quote Link to comment https://forums.phpfreaks.com/topic/52051-solved-querying-database-for-info/#findComment-256633 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.