Here is a page from my software. $cid comes from the URL and relates to an ID in the database. You should be able to get what you need from it. Hope it helps.
<?php
if(is_numeric($_GET['cid'])){
if(!isset($_POST['submit_friends'])){
echo '<form action="index.php?mod=eif&cid='.$_GET['cid'].'" method="POST">';
echo '<table border="0" cellpadding="0" cellspacing="0" width="75%">';
echo '<tr>';
echo '<td colspan="4" align="left"><b>Please enter the following information:</b><br><br></td>';
echo '</tr>';
echo '<tr>';
echo '<td style="padding-top:2px; padding-bottom:2px;" align="left">Your name:</td>';
echo '<td style="padding-top:2px; padding-bottom:2px;"><input type="text" name="sender"></td>';
echo '<td style="padding-top:2px; padding-bottom:2px;">Your e-mail:</td>';
echo '<td style="padding-top:2px; padding-bottom:2px;"><input type="text" name="sender_email"></td>';
echo '</tr>';
for($i=0;$i<=2;$i++){
echo '<tr>';
echo '<td style="padding-top:2px; padding-bottom:2px;" align="left">Friends name:</td>';
echo '<td style="padding-top:2px; padding-bottom:2px;"><input type="text" name="friend[]"></td>';
echo '<td style="padding-top:2px; padding-bottom:2px;">Friends e-mail:</td>';
echo '<td style="padding-top:2px; padding-bottom:2px;"><input type="text" name="friend_email[]"></td>';
echo '</tr>';
}
echo '<tr>';
echo '<td align="left" colspan="2" style="padding-top:2px; padding-bottom:2px;"><br><input type="submit" name="submit_friends" value=" Submit " class="submit"></td>';
echo '<td colspan="2" align="left" style="padding-top:2px; padding-bottom:2px;"><input type="checkbox" name="copy_me"> Send a copy to me.</td>';
echo '</tr>';
echo '</table>';
echo '</form>';
} else {
$sender = strip_tags($_POST['sender']);
$sender_email = $_POST['sender_email'];
if(eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$", $sender_email) == FALSE){
$sender_email = "unknown";
}
$friend = $_POST['friend'];
$friend_email = $_POST['friend_email'];
$id = 0;
foreach($friend as $f){
strip_tags($f);
}
foreach($friend_email as $fe){
if(eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$", $fe) == FALSE){
unset($friend_email[$id]);
unset($friend[$id]);
}
$id++;
}
//do the copy me part
if(isset($_POST['copy_me'])){
$friend[] = $sender;
$friend_email[] = $sender_email;
}
$vehicle = $myDb->dbFetch("SELECT * FROM ".$prefix."inventory WHERE uid='".$_GET['cid']."'");
$year = $vehicle[0]['year'];
$invent = new inventory;
$make = $invent->getMake($vehicle[0]['make']);
$model = $vehicle[0]['model'];
$url = $tb_config[0]['url']."index.php?mod=sii&id=".$vehicle[0]['uid'];
//write mail headers and message sender
$from = "FROM: ".$sender." <".$sender_email.">"
."\r\nX-MSMail-Priority: High"
."\r\nX-Mailer: Microsoft Outlook Express 6.00.2900.2180"
."\r\nX-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180"
."\r\nContent-type: text/html; charset=iso-8859-1\r\n";
$message = $tb_config[0]['co_name']." has a ".$year." ".$make." ".$model." I thought you might be interested in.<br><br>";
$message .= "You can view it here - > <a href=\"".$url."\">".$url."</a>";
$message .= "<br><br>Have a great day!";
$run_id = 0;
foreach($friend_email as $to){
$subj = "I saw this vehicle and thought of you.";
$msg = "Hi ".$friend[$run_id].".<br><br>".$message;
if(mail($to, $subj, $msg, $from)){
$sent_to = str_replace("@", " at ", $to);
$sent_to = str_replace(".", " dot ", $sent_to);
echo 'Message successfully sent to '.$sent_to.'<br>';
}//end if
} //end foreach
}//end if isset submit_friends
} else { //$_GET['cid'] == FALSE
echo 'Sorry, but no information could be obtained about the item inquired upon.<br>';
}
?>