这是我使用的代码,当我在表单中输入信息时,邮件会发送不完整的电子邮件,例如如果我将 1 添加到所有字段和电子邮件名称等,它会显示:
来自:
电子邮件:
故事:
短信:
数据:
Levrandør:
Ekstra 信息:
所以我缺乏信息。
<?php
$name = $_POST['f_name'];
$email = $_POST['email'];
$tale = $_POST['tale'];
$sms = $_POST['sms'];
$data = $_POST['data'];
$levrandor = $_POST['levrandor'];
$ekstra = $_POST['ekstra'];
$formcontent="From: $name \n Email: $email \n Tale: $tale \n Sms: $sms \n Data: $data \n Levrandør: $levrandor \n Ekstra informasjon: $ekstra";
$recipient = "post@mobilavtalen.no";
$subject = "Melding fra bruker.";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
if(mail){
header('Location: thanks.html');
}else{ echo "Email ble ikke sendt";}
?>
HTML 表单:
<div class="form_area text-left">
<form id="contact-form" action="mail.php" method="post">
<fieldset>
<label>Navn:</label>
<input type="text" placeholder="">
<label>E-mail: (Må fylles inn)</label>
<input type="email" placeholder="" required>
<label>Forbruk pr mnd (Må fylles inn):</label>
<label>Tale:</label>
<input type="text" placeholder="" required>
<label>Sms:</label>
<input type="text" placeholder="" required>
<label>Data:</label>
<input type="text" placeholder="" required>
<label>Levrandør:</label>
<input type="text" placeholder="" required>
<label>Ekstra informasjon:</label>
<textarea rows="3"></textarea><br>
<!--<input type="submit" id="submit_button" class="btn" value="Send">-->
<button name="submit" type="submit" id="submit_button">Send</button>
</fieldset>
</form>
</div>