直到最近,使用POST和PHP的基本HTML表单都运行良好。目前,它从一些计算机/设备完美邮寄,但与某些其他计算机/设备失败。
上传网络之外的某些设备提交正常,其他设备则没有。有时,一台有问题的计算机在下次尝试时工作正常。我的直觉说这是一个虚拟主机问题,因为我正在使用免费的byethost17。
这是PHP:
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$ride = $_POST['rideA'] +$_POST['rideS'];
$frogs = $_POST['bbq'] + $_POST['burg'] + $_POST['chim'] + $_POST['ces'] + $_POST['fet'];
$top = $_POST['topA'] + $_POST['topS'] + $_POST['topSt'];
$memo = $_POST['memA'] + $_POST['memS'] + $_POST['memSt'];
$fee = max($_POST['flight'], $_POST['bus'], $ride, $_POST['cruise'], $_POST['srock'], $frogs, $top, $memo);
$ambrosia = $fee * 30;
$subtotal = (618 * $_POST['flight']) + (30 * $_POST['bus']) + (65 * $_POST['rideA']) + (45 * $_POST['rideS']) + (60 * $_POST['cruise']) + (95 * $_POST['srock']) + (19 * $frogs) + (26 * $_POST['topA']) + (24 * $_POST['topS']) + (20 * $_POST['topSt']) + (21.5 * $_POST['memA']) + (16.5 * $_POST['memS']) + (13.5 * $_POST['memSt']);
$total = $subtotal + $ambrosia;
$to = '***@gmail.com';
$subject = 'Order Confirmation: ' . $_POST['a'] . ' ' . $_POST['b'];
$message = 'School: ' . 'CVHS' . "\r\n";
$message .= $_POST['a1'] . $_POST['a'] . "\r\n";
$message .= $_POST['b1'] . $_POST['b'] . "\r\n";
$message .= $_POST['c1'] . $_POST['c'] . "\r\n";
$message .= $_POST['d1'] . $_POST['d'] . "\r\n";
$message .= $_POST['e1'] . $_POST['e'] . "\r\n";
$message .= $_POST['f1'] . $_POST['f'] . "\r\n";
$message .= $_POST['g1'] . $_POST['g'] . "\r\n";
$message .= $_POST['h1'] . $_POST['h'] . "\r\n";
$message .= $_POST['flight1'] . $_POST['flight'] . "\r\n";
$message .= $_POST['bus1'] . $_POST['bus'] . "\r\n";
$message .= $_POST['rideS1'] . $_POST['rideS'] . "\r\n";
$message .= $_POST['rideA1'] . $_POST['rideA'] . "\r\n";
$message .= $_POST['cruise1'] . $_POST['cruise'] . "\r\n";
$message .= $_POST['srock1'] . $_POST['srock'] . "\r\n";
$message .= $_POST['bbq1'] . $_POST['bbq'] . "\r\n";
$message .= $_POST['burg1'] . $_POST['burg'] . "\r\n";
$message .= $_POST['chim1'] . $_POST['chim'] . "\r\n";
$message .= $_POST['ces1'] . $_POST['ces'] . "\r\n";
$message .= $_POST['fet1'] . $_POST['fet'] . "\r\n";
$message .= $_POST['topA1'] . $_POST['topA'] . "\r\n";
$message .= $_POST['topS1'] . $_POST['topS'] . "\r\n";
$message .= $_POST['topSt1'] . $_POST['topSt'] . "\r\n";
$message .= $_POST['memA1'] . $_POST['memA'] . "\r\n";
$message .= $_POST['memS1'] . $_POST['memS'] . "\r\n";
$message .= $_POST['memSt1'] . $_POST['memSt'] . "\r\n" . "\r\n";
$message .= 'The Paramount NYC' . "\r\n";
$message .= $_POST['ab1'] . $_POST['ab'] . "\r\n";
$message .= $_POST['ac1'] . $_POST['ac'] . ' ' . $_POST['acday'] . ', ' . $_POST['acyear'] . "\r\n";
$message .= $_POST['ad1'] . $_POST['ad'] . ' ' . $_POST['adday'] . ', ' . $_POST['adyear'] . "\r\n" . "\r\n";
$message .= $_POST['bb1'] . $_POST['bb'] . "\r\n";
$message .= $_POST['bc1'] . $_POST['bc'] . ' ' . $_POST['bcday'] . ', ' . $_POST['bcyear'] . "\r\n";
$message .= $_POST['bd1'] . $_POST['bd'] . ' ' . $_POST['bdday'] . ', ' . $_POST['bdyear'] . "\r\n" . "\r\n";
$message .= $_POST['iroom1'] . $_POST['iroom'] . "\r\n";
$message .= $_POST['aname1'] . $_POST['aname'] . ' ';
$message .= $_POST['bname1'] . $_POST['bname'] . "\r\n";
$message .= $_POST['cname1'] . $_POST['cname'] . ' ';
$message .= $_POST['dname1'] . $_POST['dname'] . "\r\n";
$message .= $_POST['ename1'] . $_POST['ename'] . ' ';
$message .= $_POST['fname1'] . $_POST['fname'] . "\r\n";
$message .= $_POST['gname1'] . $_POST['gname'] . ' ';
$message .= $_POST['hname1'] . $_POST['hname'] . "\r\n" . "\r\n";
$message .= $_POST['rroom1'] . $_POST['rroom'] . "\r\n";
$message .= $_POST['jname1'] . $_POST['jname'] . ' ';
$message .= $_POST['kname1'] . $_POST['kname'] . "\r\n";
$message .= $_POST['lname1'] . $_POST['lname'] . ' ';
$message .= $_POST['mname1'] . $_POST['mname'] . "\r\n";
$message .= $_POST['nname1'] . $_POST['nname'] . ' ';
$message .= $_POST['oname1'] . $_POST['oname'] . "\r\n";
$message .= $_POST['pname1'] . $_POST['pname'] . ' ';
$message .= $_POST['qname1'] . $_POST['qname'] . "\r\n";
$message .= 'Payment type: ' . $_POST['payment'] . "\r\n";
$message .= 'Sub-total: ' . $subtotal . "\r\n";
$message .= 'Ambrosia Fee: ' . $ambrosia . "\r\n";
$message .= 'Total: ' . $total . "\r\n";
mail($to, $subject, $message);
header('Refresh: 1; URL= http://***.com');
}
?>
这些是js电话:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
这是javascript代码:
<script>
function validateForm() {
var xa = document.forms["main"]["a"].value;
var xb = document.forms["main"]["b"].value;
var xc = document.forms["main"]["c"].value;
var xd = document.forms["main"]["d"].value;
var xe = document.forms["main"]["e"].value;
var xf = document.forms["main"]["f"].value;
var xg = document.forms["main"]["g"].value;
var xh = document.forms["main"]["h"].value;
if (xa == null || xa == "") {
alert("First name must be filled out");
document.forms["main"]["a"].focus();
return false;}
if (xb == null || xb == "") {
alert("Last name must be filled out");
document.forms["main"]["b"].focus();
return false;}
if (xc == null || xc == "") {
alert("Phone number must be filled out");
document.forms["main"]["c"].focus();
return false;}
if (xd == null || xd == "") {
alert("Email must be filled out");
document.forms["main"]["d"].focus();
return false;}
if (xe == null || xe == "") {
alert("Street name must be filled out");
document.forms["main"]["e"].focus();
return false;}
if (xf == null || xf == "") {
alert("City must be filled out");
document.forms["main"]["f"].focus();
return false;}
if (xg == null || xg == "") {
alert("State must be filled out");
document.forms["main"]["g"].focus();
return false;}
if (xh == null || xh == "") {
alert("Zipcode must be filled out");
document.forms["main"]["h"].focus();
return false;}
}
</script>
我不知道是什么原因造成了这个虚拟主机之外的问题。谢谢!
答案 0 :(得分:0)
我最好的猜测是你正在使用的mail()函数的一些问题。试试这个link
您也可以尝试以下代码。
if(mail($to, $subject, $message)){
echo "Email sent";
header('Refresh: 1; URL= http://***.com');
}else{
echo "Unable to send email";
}
如果电子邮件已发送,则 mail()
函数返回true,然后您可以重定向到下一页。
如果有帮助,请告诉我