I know, this topic is not new but I have a problem and can't go on. So I would be happy if someone could help me.
I have a form
on my website
and now, I want to send the input to my email-address. But when I click the submit-button
, I got no email and it opens my php
code. what is wrong?
That is my html code:
<form action="sendMail.php" method="post" name="form">
<table border="0" cellspacing="0" cellpadding="2">
</tr>
<tr>
<td>Vorname:</td>
<td>
<input maxlength="50" name="vorname" size="45" type="text" />
</td>
</tr>
<tr>
<td>Email:</td>
<td>
<input name="email" size="45" type="text" />
</td>
</tr>
<tr>
<td>Mitteilung:</td>
<td><textarea cols="30" rows="5" name="msg" placeholder="Ihre Mitteilung"></textarea></td>
</tr>
<tr></tr>
<tr>
<td>
<input type="submit" name="submit" value="Abschicken" />
</td>
</tr>
</tbody>
</table>
</form>
And that is my php code:
<?php
if(isset($_POST['submit'])){
$name=$_POST['name'];
$vorname=$_POST['vorname'];
$email=$_POST['email'];
$msg=$_POST['msg'];
$to='x.y@zzz.com';
$subject='Form Submission';
$message="Name :".$name."\n"."Vorname :".$vorname."\n"."Wrote the following :"."\n\n".$msg;
$headers="From: ".$email;
if(mail($to, $subject, $message, $headers)){
echo "<h1>Sent Successfully! Thank you"." ".$name.", We will contact you shortly!</h1>";
}
else{
echo "Something went wrong!";
}
}
?>
And when I click submit
, I get this:
Thats what happen in my browser
Thanks a lot for your help!