I have trouble getting my contact form to work and forward messages to mail.
I receive the following message when i submit my message:
Screenshot :
As far as i know it should be working fine. Furthermore I have used Materialize CSS. The echo messages are in Danish (don't mind those), they just print "Thanks for your message" and "Error".
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$formcontent = "Fra: $name \n Besked: $message";
$recipient = "[email protected]";
$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>
Missing name
attribute
in your all input fields .
<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>
Note : Input without name attributes
are ignored value not send to server .