jestem kompletnym laikiem, a potrzebuję tego skryptu na stronę. Chodzi mi o wycenę zamówienia z możliwością wysłania do mnie na email.
Korzystając z innych for i źródeł skleciłem coś takiego:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="pl"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <script type="text/javascript"> google.load("jquery", "1"); </script> <script type="text/javascript"> function update(){ var sum = 0; $("#calculator > tbody > tr").each(function(){ var price = parseFloat($(this).find("td:eq(2)").text()); var amount = parseFloat($(this).find("td:eq(3)").find("input:first").val()); var value = $(this).find("td:eq(4)"); if (amount > 0) { value.text(price*amount); sum += price*amount; } else { value.text(0); } }); $("#summary").text(sum); } $(document).ready(function(){ update(); $("#calculator input").keyup(function(){ update(); }); }); </script> </head> <body> <?php if (count($_POST)) { $email = 'adres@email.pl'; $subject = 'Wycena'; $message = 'Formularz wysłany'; $error = 'Wystąpił błąd podczas wysyłania formularza'; $charset = 'windows-1250'; $head = "MIME-Version: 1.0\r\n" . "Content-Type: text/plain; charset=$charset\r\n" . "Content-Transfer-Encoding: 8bit"; $body = ''; foreach ($_POST as $name => $value) { if (is_array($value)) { for ($i = 0; $i < count($value); $i++) { $body .= "$name=" . (get_magic_quotes_gpc() ? stripslashes($value[$i]) : $value[$i]) . "\r\n"; } } else $body .= "$name=" . (get_magic_quotes_gpc() ? stripslashes($value) : $value) . "\r\n"; } echo mail($email, "=?$charset?B?" . base64_encode($subject) . "?=", $body, $head) ? $message : $error; } else { ?> <form action="?" method="post"> <table id="calculator"> <thead> <tr> </tr> </thead> <tfoot> <tr> </tr> </tfoot> <tbody> <tr> </tr> <tr> </tr> <tr> </tr> </tbody> </table> <input type="submit" value=" wyslij " / > </form> <?php } ?> </body> </html>
Wszystko jest ok, ale nie w mailu ze strony nie ma danej Razem. Poza tym, nie wiem jak skrócić do dwóch miejsc po przecinku. Proszę o pomoc.