views:

68

answers:

5

I have the following form.

<h1>Please Confirm Your Order</h1>
<p class="padnmgn">Please confirm your order before clicking the Email Your Order Now button below. If you have changes,
<?php echo anchor("myshop/cart", "go back to your shopping cart");?>.</p><br />


<form method="POST" 
        action="myshop/emailorder" 
        accept-charset="utf-8">


<?php
$TOTALPRICE = $_SESSION['totalprice'];

if (count($_SESSION['cart'])){
    $count = 1;
    foreach ($_SESSION['cart'] as $PID => $row){ 
        echo "<p class='padnmgn'><b>". $row['count'] . " " . $row['name'] . " @ " . $row['price']."</b></p><br/>\n";
        echo "<input type='hidden' name='item_name_".$count."' value='".$row['name']."'/>\n";
        echo "<input type='hidden' name='item_quantity_".$count."' value='".$row['count']."'/>\n";
        echo "<input type='hidden' name='item_price_".$count."' value='".$row['price']."'/>\n";
        echo "<input type='hidden' name='item_currency_".$count."' value='NOK'/>\n";
        echo "<input type='hidden' name='ship_method_name_".$count."' value='Posten'/>\n";
        echo "<input type='hidden' name='ship_method_price_".$count."' value='65.00'/>\n";
        $TOTALPRICE += 65;
        $count++;
    }
}
echo "<p class='padnmgn'><b>SHIPPING: 65</b></p>\n";
echo "<p class='padnmgn'><b>TOTAL (w/shipping): ". $TOTALPRICE. "</b></p>\n";
echo form_submit('submit', 'Email Order!');
?>

</form>

I want to make it to send an email to me when a customer click "Submit".

I want to add the subject and message with the details and total since I am not storing the details in my database.

I am looking for code or resources so that I can modify them.

A: 

Best bet is to start with mail(), Php.net mail() which will allow you to send emails. The other thing of course is to use a fully fledged library for the job.

There are lots around, http://swiftmailer.org/ http://www.phpguru.org/static/htmlMimeMail5/ http://phpmailer.worxware.com/

I'm sure there are PEAR classes for this kind of thing also :)

DavidYell
A: 

Symfony 1.3+ embeds Swift Mailer version 4.1 which allows you to send email easily.

If your are building a site. symfony is a good framework and it is MVC :-)

Tommy
+1  A: 

Pass all your order details in the $_SESSION var to $body and send it using the mail(..) function. If not try one of a existing library/classes mentioned by @DavidYell to do the job.

$body = "<h1>Put all your html</h1> order details here";
$to = "[email protected]";
$subject = "Order Details";
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= "Reply-to: [email protected]\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: My From Address <[email protected]>' . "\r\n";
mail($to, $subject, $body, $headers);
randika
And sanitize everything users can change... :)
Karsten
A: 
$to = "[email protected]";
$subject = "A E-mail";
$message = "How are you?";
$from = "[email protected]";
$headers = "From: $from";

mail($to,$subject,$message,$headers);

That would be about the simplest way - although you should add error handling. Swiftmailer, as someone above suggested is more full featured, and very easy to use.

Erik
A: 

Nothing Better Than Using PHP Mailer

Hint: WordPress uses it.

amindzx