I am setting up a shift exchange page on my company site. to get to this individuals must log in so I can carry their ID and email through out the site with sesions. On the shift page I give them the option to give up or pick up shifts. My problem is generating an email that will go to each of these parties and contain data from the table. here is the code (sorry so long), any ideas greatly appreciated.
Thanks
Pat
@ $db = mysql_pconnect("localhost", "user", "pass");
if(!$db)
{echo"Error: Could not connect to database. Please try again later.";
exit;
}
mysql_select_db("secure");
if (isset($pickup)) {
//the sql query can't work like that!!!
// you have to use the fieldnames in the database
// lets presume that date and hospital are the
// fieldnames -- when you wanna get all fields
// just select from table
/****************
$sql = "SELECT $date, $hospital, $shift, $physician, $email_shift FROM table
WHERE entry=$pickup";
*******************/
$sql = "SELECT date, hospital, shift, physician, email_shift FROM table WHERE entry= '$pickup'";
//get a result
$result = mysql_query($sql) or die("Could not find record." .mysql_error());
//lets fill an array with data
$row = Mysql_fetch_array($result);
$date1 = $row["date"];
$hospital1 = $row["hospital"];
$shift1 = $row["shift"];
$physician1 = $row["physician"];
$email_shift1 = $row["email_shift"];
// just trying to see if I got any data.
print "$date1";
print "$hospital1";
print "$shift";
print "$physician1";
print "$email_shift1";
print "hello world";
// Email the new password to the person.
$message = "$uid, you picked up the $shift1 shift at $hospital1 on $date1 from $physician1.
";
mail($email,"Shift Taken",
$message, "From:Shift Master <huntpat@sc.rr.com>");
mail($email_shift1,"Shift Picked Up",
$message, "From:Shift Master <huntpat@sc.rr.com>");
$sql = "DELETE FROM shifts
WHERE entry=$pickup";
if (@mysql_query($sql)) {
echo("<p>The shift has been picked up.</p>");
unset($pickup);
} else {
echo("<p>Error deleting evaluation: " .
mysql_error() . "</p>");
}
}