Jump to content

Recommended Posts

I have a question about the best way to do this.

 

I have a web site where you can put someone on an "invite" list, now when a person posts content only people on this "invite" list can view the content.

 

All of the "invites" are stored in the same table with just the member numbers for the poster and the invited people being changed.

 

So my question is, when the page is loaded, what would be the best way to check the database to see if the member number of the person viewing the page is in the "invite" table??

 

So for example if your member # is 1202, and member # 1504 posted some content it would scan the database for member # 1202 on the invite list of member # 1504.

 

I hope I am being clear about what I am saying here  ???

Link to comment
https://forums.phpfreaks.com/topic/84777-solved-help-with-db-query/
Share on other sites

Something like this should do the trick:

 

<?php
$id1 = $_SESSION['id']; //im assuming you have the currently logged in user's in stored in a session?
$id2 = $_GET['id']; //and the user ID of the posted content in the $_GET array?
$sql = "SELECT COUNT(*) FROM tbl WHERE col1=$id1 AND col2=$id2";
$result = mysql_query($sql) or die(mysql_error());
$num = mysql_result($result,0);
if($num != 1){
echo 'You are not authorised to view this!';
exit;
}
//continue with page
?>

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.