I tried to make a contact form for a website made in WP and i added the following code to the theme and i can’t figure it out if i did it in the right way. So i am using the following code:
<?php
$action=$_REQUEST['action'];
if ($action=="") /* display the contact form */
{
?>
<form method="post" action="#">
<input type="hidden" name="action" value="submit">
<div class="row 50%">
<div class="6u 12u(mobile)"><input type="text" name="name" placeholder="Nume" /></div>
<div class="6u 12u(mobile)"><input type="email" name="email" placeholder="Email" /></div>
</div>
<div class="row 50%">
<div class="12u"><textarea name="message" placeholder="Mesajul tau catre noi..." rows="6"></textarea></div>
</div>
<div class="row">
<div class="12u">
<ul class="actions">
<li><input type="submit" value="Trimite Mesajul" /></li>
</ul>
</div>
</div>
</form>
<?php
}
else /* send the submitted data */
{
$name=$_REQUEST['name'];
$email=$_REQUEST['email'];
$message=$_REQUEST['message'];
if (($name=="")||($email=="")||($message==""))
{
echo "All fields are required, please fill <a href="">the form</a> again.";
}
else{
$from="From: $name<$email>rnReturn-path: $email";
$subject="Message sent using your contact form";
mail("myemail@gmail.com", $subject, $message, $from);
echo "Email sent!";
}
}
?>
Can you tell me were i am failing? And why?
you should also add the header variable with below value, if you use the html in message: