好的,所以我一直在尝试在 php 中创建一个非常简单的订单系统,它由一页不同的表单字段组成,您可以填写并提交,提交时会有一个验证页面,该页面将发送邮件或声明错误. 它完美地工作了一周左右,然后我对文件进行了细微的更改并上传了它们,然后将它们改回来。现在它拒绝工作。这是我的两个页面的代码:
</head>
<body>
<form name="detaljer" action="index.php" onsubmit="return validateForm();"
method="POST">
<p>Ange önskad kaliber</p>
<select name="kaliberCombo">
<option value=".22">.22</option>
<option value="9mm">9x19mm</option>
<option value=".40">.40</option>
<option value=".45">.45</option>
<option value=".357">.357</option>
</select>
</br>
<p>Declare number:</p>
<input type="number" name="antal" min="100">
<p>Name*:</p><input type="text" name="fnamn"><input type="text" name="enamn">
<p>Email*:</p><input type="text" name="email">
<p>Adress:</p><input type="text" name="address">
<p>Phone*:</p><input type="text" name="telefon">
<br>
<p>Add a comment</p>
<textarea name="comment" rows="5" cols="50" maxlength="300">
</textarea>
<input type="submit" value="submit">
<br><p>* required fields</p>
</form>
<script src="js/main.js"></script>
</body>
上面还有一些 jscript,尽管这无关紧要。
然后是验证页面:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<?php
$kaliber=$_POST['kaliberCombo'];
$antal = $_POST['antal'];
$fornamn = $_POST['fnamn'];
$efternamn = $_POST['enamn'];
$mail = $_POST['email'];
$address = $_POST['address'];
$telefon = $_POST['telefon'];
$kommentar = $_POST['comment'];
$sender = "Anyname";
$sendername = "examplemail@example.com";
$recipient = "gbreisch@hotmail.com";
$recipientname = "gbreisch";
$subject = "Bestallning!";
$message = "Bestallning \n
$fornamn $efternamn har beställt
\n'$antal'st $kaliber \n
Email: $mail\n
Telefon: $telefon\n
Kommentar som gavs av kund: $kommentar";
$date = date(DATE_RFC2822);
$mid = "<" . sha1(microtime()) . "@" . $_SERVER['HTTP_HOST'] . ">";
mb_internal_encoding("UTF-8");
$sendername = mb_encode_mimeheader($sendername);
$recipientname = mb_encode_mimeheader($recipientname);
$headers =<<<EOT
From: $sendername <$sender>
Date: $date
Message-ID: $mid
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
EOT;
$status = mb_send_mail("$recipientname <$recipient>", $subject, $message, $headers, "-f$sender");
if(!$status) {
echo "Could not send your order.";
}
else {
echo "Order sent!";
}?>
</body>
</html>
自从代码最近运行良好以来,这让我发疯了,而且我尝试使用旧副本,它拒绝发送。