I have some scripts for a shopping cart and product list and whatnot. Now I need to mail not only the contents of the form that is displayed with the cart, but the contents of the cart. I have some general idea of how to do this but I am unsure whether or not this one piece of code is viable or not. Any help is much appreciated.
I am just wondering if these parts are correct(can I do that? Put a while loop into a variable?):
$cart = while($row = mysql_fetch_array($result) or die(mysql_error()))
{
echo $row[itemId];
echo $row[qty];
}
$mail = @mail($to,$_POST['subj'],$_POST['msg'],$cart,$headers);
//The Form --- "form.html"
<form action="mail.php" method="post">
Email: <input type="text" name="frmail">
Message: <textarea name="msg"></textarea>
Subject: <input type="text" name="subj">
<input type=submit name="submit" value="Send">
</form>
//The mail script --- "mail.php"
$to = "mail@mail.com";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$cart = while($row = mysql_fetch_array($result) or die(mysql_error()))
{
echo $row[itemId];
echo $row[qty];
}
$mail = @mail($to,$_POST['subj'],$_POST['msg'],$cart,$headers);
// The "@" sign before the mail() call suppresses printing of errors
// that may occur. The test below will check for errors instead:
if(!$mail){
echo "Order not sent! Please try later...";
}else{
echo "Order sent successfully!";
}