<?
session_start();
ob_start();
include_once("../dbconnect.php");
for($i=0;$i<count($_POST['customers']);$i++)
{
	$getuemail=mysql_fetch_array(mysql_query("select Email from register where user_id=".$_POST['customers'][$i]));
  $stringids.=$_POST['customers'][$i].",";
   $string.=$getuemail[Email].",";
}
 $get=substr($string,0,-1); 
 $getids=substr($stringids,0,-1);

 $updatecptable=mysql_query("update coupons set coupon_users='".$getids."' where coupon_id=".$_POST[couponlastid]);

    $getcoupondata=mysql_fetch_array(mysql_query("select * from coupons where coupon_id=".$_POST[couponlastid]));
    $message=$_POST['giftmessage'];
	echo "Regards
	www.sisboxusa.com";
	$email_subject = $_POST['emailsubject']; 
	$email_to = "To: ".$get;
	$email_message = $message;
	$email_from=$_POST['mailfrom']; 
    $headers = "From:   ".$email_from;
	mail($email_to,$email_subject,$email_message,$headers); 
	header("location:giftcoupons.php?csent=csent");
?>