Jump to content

Recommended Posts

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);

 

?>

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 by SocialCloud
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.