我无法让我的联系表单工作并将邮件转发给邮件。
我提交邮件时收到以下消息:
屏幕截图:
据我所知它应该工作正常。此外,我使用了Materialise CSS。回音信息是丹麦语(不介意),只是打印“谢谢你的消息”和“错误”。
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$formcontent = "Fra: $name \n Besked: $message";
$recipient = "mail@mail.com";
$subject = "Kontaktformular";
$mailheader = "Fra: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Fejl!");
echo "Tak for din besked!";
?>
<div class="container">
<div class="row">
<form action="mail.php" method="POST" class="col s12">
<div class="row">
<div class="row">
<div class="input-field col s6">
<input id="name" type="text" class="validate">
<label for="name">Navn</label>
</div>
<div class="input-field col s6">
<input id="email" type="text" class="validate">
<label for="email">E-mail</label>
</div>
</div>
<div class="row">
<div class="input-field col s12">
<textarea id="message" class="materialize-textarea"></textarea>
<label for="message">Besked til Safemove</label>
</div>
</div>
<div class="row">
<div class="col m12">
<button class="btn waves-effect waves-light background-orange" type="submit" name="action">Send besked
<i class="material-icons right">send</i>
</button>
</div>
</div>
</div>
</form>
</div>
</div>
答案 0 :(得分:1)
在所有输入字段中遗漏name
attribute
。
<input id="name" name="name" type="text" class="validate">
.. ^^^^^^^^^^
<input id="email" name="email" type="text" class="validate">
..
<textarea id="message" name="message" class="materialize-textarea" > </textarea>
注意:忽略不带name attributes
的输入值不会发送到服务器。