#!/usr/bin/perl use CGI qw(:standard); print "Content-type: text/html; charset=utf8\n\n"; #$str = "?"; $i = "1"; $total = "0"; print "

Оформление заказа

"; $act = param("act"); $lname = param("lname"); $fname = param("fname"); $tname = param("tname"); $phone = param("phone"); $address = param("address"); $idop = param("dop"); if ($act eq "") { print ""; print ""; print ""; while () { $name = param("item_name_$i"); $num = param("item_number_$i"); $quant = param("quantity_$i"); $price = param("amount_$i"); $dop = param("os0_$i"); $sum = $quant * $price; if ($name eq "") {last;} print "\n"; print ""; print ""; print ""; print ""; print ""; $total = $total + $sum; $i++; } print "
НаименованиеКоличествоДополнительноЦенаСумма
$num$name$quant$dop$price$sum

ИТОГО: $total РУБЛЕЙ
"; print "
Фамилия *
Имя *
Отчество
Контактный телефон *
Адрес доставки *
Дополнительно
"; } if ($act eq "send") { if ($lname ne "" and $fname ne "" and $phone ne "" and $address ne "") {$ok = "ok";} print ""; $str = "Content-type: text/html; charset=utf8\n\n

Заказ

НаименованиеКоличествоДополнительноЦенаСумма
"; print ""; print ""; while () { $name = param("item_name_$i"); $num = param("item_number_$i"); $quant = param("quantity_$i"); $price = param("amount_$i"); $dop = param("os0_$i"); $sum = $quant * $price; if ($name eq "") {last;} print "\n"; $str = sprintf ("%s \n", $str); print ""; print ""; print ""; print ""; print ""; $total = $total + $sum; $i++; } print "
НаименованиеКоличествоДополнительноЦенаСумма
$num$name$quant$dop$price$sum
$num$name$quant$dop$price$sum

ИТОГО: $total РУБЛЕЙ
"; $str = sprintf ("%s
ИТОГО: $total РУБЛЕЙ
", $str); if ($ok ne "ok") { print "
Заполнены не все поля, помеченные \" * \"

Фамилия *
Имя *
Отчество
Контактный телефон *
Адрес доставки *
Дополнительно
"; } else { print "
Заказ принят

Фамилия$lname
Имя$fname
Отчество$tname
Контактный телефон$phone
Адрес доставки$address
Дополнительно$idop
"; $str = sprintf ("%s
Заказ принят

Фамилия$lname
Имя$fname
Отчество$tname
Контактный телефон$phone
Адрес доставки$address
Дополнительно$idop
", $str); open(MAIL, "|/usr/lib/sendmail -t"); print MAIL "Content-type: text/html; charset=utf8;\n"; print MAIL "To: pressvs\@bk.ru\n"; # print MAIL "To: mar7\@mail.ru\n"; print MAIL "From: root\@spektrmebeli.ru \n"; print MAIL "Subject: Заказ\n"; print MAIL "$str\n"; close (MAIL); } }