<?php
ob_start();
session_start();
include 'connect.php';

//$from=$_SESSION['adminemail'];

if(isset($_GET['send']))
{
$id=$_GET['id'];
$email=$_GET['email'];

$from='admin@grotec.in';

$email=array($email);

$sel=mysqli_query($conn,"select * from purchase_order where orderno='$id'");
$sel1=mysqli_fetch_assoc($sel);

$cus=mysqli_query($conn,"select * from supplier where ID='$sel1[supplier]'");
$cus1=mysqli_fetch_assoc($cus);

$subject="Hello ".$cus1['name'];
$message="As your request here is our purchase order with this mail. Please check and let us know. <br /> <br />
Please click the following link to view your Invoice. <br />
<b><a href='http://grotec.in/printpurchaseorder.php?id=".$id."'>View</a></b><br><br>";

$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: <'. $from .'>' . "\r\n";
$headers .= 'Reply-To: admin@grotec.in' . "\r\n";

if($email && $id)
{
mail(implode(',', $email),$subject,$message,$headers);

//echo"$email&$subject&$message&$headers";

header("location:viewpurchaseorder.php?id=".$id."");
}

else
{
header("location:viewpurchaseorder.php?id=".$id."&s=3");
}

}

ob_flush();

?>