jlindsey Posted November 29, 2012 Share Posted November 29, 2012 I need the code which basically allows a user to view data in the database except for their own. What happens is people can view a gift registry by searching. I want them to be able to pull up everyone else s data except their own. I have posted the script below. <?php if($_GET) { $searchTerm = $_GET['keyword']; $searchTerm2 = $_GET['keyword2']; $dbuser = $_GET['FirstName']; $dbuser1 = $_GET['LastName']; if ($searchTerm) { if ($searchTerm2) { $connect = mysql_connect("localhost","#####","#####"); if($connect) { mysql_select_db("users",$connect); $query = "SELECT * FROM users WHERE FirstName='$searchTerm' AND LastName='$searchTerm2'"; $results = mysql_query($query); while($row = mysql_fetch_array($results)) { $output .= "<b>First Name:</b> " . $row['FirstName'] . "<br />"; $output .= "<b>Last Name:</b> " . $row['LastName'] . "<br />"; $output .= "<b>User ID:</b> " . $row['userid'] . "<br />"; $output .= "<b>City:</b> " . $row['city'] . "<br />"; $output .= "<b>State:</b> " . $row['state'] . "<br />"; $output .= "<b>Christmas Wish List Below:</b> " . "<br />"; $output .= "<b>(If the family member has included a link, you can get to the web site by clicking the gift.)</b> " . "<br />"; $output .= "<a href=".$row['Link'] . ">".$row['Gift'] . "</a>"; $output .= $row['purchased_gift'] . "</a><br>"; $output .= "<a href=".$row['Link2'] . ">".$row['Gift2'] . "</a>"; $output .= $row['purchased_gift2'] . "</a><br>"; $output .= "<a href=".$row['Link3'] . ">".$row['Gift3'] . "</a>"; $output .= $row['purchased_gift3'] . "</a><br>"; $output .= "<a href=".$row['Link4'] . ">".$row['Gift4'] . "</a>"; $output .= $row['purchased_gift4'] . "</a><br>"; $output .= "<a href=".$row['Link5'] . ">".$row['Gift5'] . "</a>"; $output .= $row['purchased_gift5'] . "</a><br>"; $output .= "<a href=".$row['Link6'] . ">".$row['Gift6'] . "</a>"; $output .= $row['purchased_gift6'] . "</a><br>"; $output .= "<a href=".$row['Link7'] . ">".$row['Gift7'] . "</a>"; $output .= $row['purchased_gift7'] . "</a><br>"; $output .= "<a href=".$row['Link8'] . ">".$row['Gift8'] . "</a>"; $output .= $row['purchased_gift8'] . "</a><br>"; $output .= "<a href=".$row['Link9'] . ">".$row['Gift9'] . "</a>"; $output .= $row['purchased_gift9'] . "</a><br>"; $output .= "<a href=".$row['Link10'] . ">".$row['Gift10'] . "</a>"; $output .= $row['purchased_gift10'] . "</a><br>"; $output .= "<a href=".$row['Link11'] . ">".$row['Gift11'] . "</a>"; $output .= $row['purchased_gift11'] . "</a><br>"; $output .= "<a href=".$row['Link12'] . ">".$row['Gift12'] . "</a>"; $output .= $row['purchased_gift12'] . "</a><br>"; $output .= "<a href='purchasegifts2.php' style=color:#090000>PURCHASE GIFTS HERE</a><br>"; } echo $output; } else { die(mysql_error()); } } else echo "You Must Enter a Last Name."; } else echo "You Must Enter a First Name."; } mysql_close($connect); ?> Quote Link to comment https://forums.phpfreaks.com/topic/271330-need-help-with-what-users-can-view-when-they-search/ Share on other sites More sharing options...
MDCode Posted November 29, 2012 Share Posted November 29, 2012 (edited) Well all you have to do is match the search term to their session <?php if($searchTerm == $_SESSION['variable'] && $searchTerm2 == $_SESSION['other']) { echo " boo you cant search for yourself"; } else { // process request } ?> Edited November 29, 2012 by SocialCloud Quote Link to comment https://forums.phpfreaks.com/topic/271330-need-help-with-what-users-can-view-when-they-search/#findComment-1396147 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.