Mail function php, hvad gør jeg galt?
Jeg er ikke den store programmerings haj, så håbede på der var en herinde der kunne rette dette script til så det virker, for jeg har aldrig lavet en mail function før...<?php
session_start();
include("config.php");
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>kvittering</title>
</head>
<body>
<?php
$sql = "select * from e_orders order by o_id desc limit 1";
$query = mysqli_query($db,$sql) or die (mysqli_error($db));
$res = mysqli_fetch_array($query);
// multiple recipients
$to = 'mit@eksempel.dk' . ', '; // note the comma
$to .= ''.$res["o_mail"].'';
// subject
$subject = 'Ordrebekræftelse eksempel.dk';
// message
echo $message = '<table border="0" align="center" width="980px" cellspacing="15" >';
echo '<tr>';
echo '<td><strong>'; echo 'Tak for din bestilling:</strong></td>';
echo '</tr>';
echo '<tr>';
echo '<td colspan="2"><hr></td>';
echo '</tr>';
echo '<tr>';
echo '<td>Bestillingsdato:'; $sql = "select * from e_orders order by o_id desc limit 1";
$query = mysqli_query($db,$sql) or die (mysqli_error($db));
$res = mysqli_fetch_array($query); echo $res['o_date']; echo '</td>
</tr>
<tr>
<td>';
echo "".$res['o_first']." ".$res['o_last']."<br />";
echo "".$res['o_adr']."<br />".$res['o_sipcode']." ".$res['o_city']."<br />";
echo "E-mail: ".$res['o_mail']."<br />";
echo "Tlf.: ".$res['o_tlf']."";
echo '</td>
</tr>
<tr>';
$count = count(@$_SESSION['basket']['fisk_id']);
echo '<table width="980px" border="0" align="center" cellspacing="5">
<tr>
<td width="164" bgcolor="#77BBFF">Produkt: </td>
<td width="64" bgcolor="#77BBFF">Stk/Gram: </td>
<td width="164" bgcolor="#77BBFF">Pris:</td>
<td width="164" bgcolor="#77BBFF">Antal bestilte gram/fisk: </td>
<td width="164" bgcolor="#77BBFF" style="text-align:right;">SubTotal:</td>
</tr>';
$totalprice = 0;
for($i = 0; $i < $count;$i++){
echo "<tr>";
echo "<td style='text-align:left;' style='color:#000' bgcolor='#F2F4FF'>".$_SESSION['basket']['fisk_art'][$i]."</td>";
echo "<td style='color:#000' bgcolor='#F2F4FF'>".$_SESSION['basket']['fisk_gram'][$i]." </td>";
echo "<td style='color:#000' bgcolor='#F2F4FF'>".$_SESSION['basket']['fisk_pris'][$i]." Kr.</td>";
echo "<td style='text-align:left;' style='color:#000' bgcolor='#F2F4FF'>".$_SESSION['basket']['count'][$i]."</td>";
$price = $_SESSION['basket']['fisk_pris'][$i] / $_SESSION['basket']['fisk_gram'][$i];
$total = $price * $_SESSION['basket']['count'][$i];
echo "<td style='text-align:right;' style='color:#000' bgcolor='#F2F4FF'>".$total." DKK.</td>";
$totalprice = $totalprice + $total;
echo "</tr>";
};
echo "</table>";
echo "<table width='980px' border='0' align='center' cellspacing='0'>";
echo "<tr>";
echo "<td><hr></td>";
echo "</tr>";
echo "</table>";
echo "<table width='980px' border='0' align='center' cellspacing='0'>";
echo "<tr>";
echo "<td>Total Pris inkl. moms: </td>";
echo "<td colspan='3' style='text-align:right;'>"; echo "".$totalprice.""; echo " DKK.</td>";
echo "</tr>";
echo "</table>";
echo "<table width='980px' border='0' align='center' cellspacing='0'>";
echo "<tr>";
echo "<td><hr></td>";
echo "</tr>";
echo "<tr>";
echo "<td>Hvis der skulle være spørgsmål, er du mere end velkommen til at ringe.<br /><br /></td>";
echo "</tr>";
echo "<tr>";
echo "<td>Mvh. "; $sql = "select * from text where text_id=2";
$query = mysqli_query ($db, $sql) or die (mysqli_error($db));
$res = mysqli_fetch_array ($query); echo nl2br($res['text_b']);
echo "</td>";
echo "</tr>";
echo "</table>";
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$sql = "select * from e_orders order by o_id desc limit 1";
$query = mysqli_query($db,$sql) or die (mysqli_error($db));
$res = mysqli_fetch_array($query);
// Additional headers
$headers .= 'To: Victor <mit@eksempel.dk>' . "\r\n";
$headers .= 'From: eksempel <mit@eksempel.dk>' . "\r\n";
$headers .= 'Cc: "'.$res["o_mail"]. "\r\n";
// Mail it
if(@$_GET['page'] == "kvittering"){
mail($to, $subject, $message, $headers);
};
?>