Location: PHPKode > projects > Mozart > Mozart-0.0.4/addtomylist.php
<?
// called from: updcontact.php, contactdisplay.php, display.php
// description: inserts contact_id and user_id into userxcont table
//
include("connect.inc");
include("reqlogin.inc");

// first we need to make sure the entry doesn't already exist
$CheckEntrySQL = "SELECT xuser_id FROM userxcont WHERE xuser_id = '$UserID' and xcont_id = '$id'";
$CheckEntry    = mysql_query($CheckEntrySQL);
// if the entry already exists, then we return to the contact listing screen
if ($checkentry = mysql_fetch_array($CheckEntry)) {
   $Message = "Contact Already Exists In Your List";
   include("contactlist.php");
   exit;
}
// if we get here, shove it in the table
$NewEntrySQL = "INSERT INTO userxcont (userxcont_id, xuser_id, xcont_id) VALUES (NULL, '$UserID', '$id')";
$NewEntry    = mysql_query($NewEntrySQL);

// a little error checking never hurt anyone, right?
$errno = mysql_errno($db);
$error = mysql_error($db);
if ($errno != 0) {
   $Message = "In addtomylist.php $errno: $error";
   include("contactlist.php");
   exit;
}

// now back to the main contact listing screen
$Message = "Contact Successfully Added To Your List";
include("contactlist.php");
?>
Return current item: Mozart