Hello, I am mostly into frontend and now I am trying to link my webform with php and make her send the data to my email, here is the form:
<form action="p.php" id="form" method="post" name="form">
<input class="lang-en" name="client" placeholder="Your Name" type="text" value="" required pattern="[A-Za-z-0-9]+\s[A-Za-z-'0-9]+" title="firstname lastname">
<input class="lang-en" name="email" placeholder="Your Email" type="email" value="" required>
<textarea class="lang-en" name="comment" placeholder="Your Comments Here..." id="comment"></textarea>
<input class="o-btn lang-en" type="Submit" value="Submit">
</form>
and my php code:
[php]<?php
if(isset($_POST[‘send’])) {
$to = ‘[email protected]’;
$subject = ‘Message from your Site’;
$message = 'Name: ’ . $_POST[‘name’] . “\r\n\r\n”;
$message .= 'Email: ’ . $_POST[‘email’] . “\r\n\r\n”;
$message .= 'Comments: ’ . $_POST[‘comments’];
$headers = “From: [email protected]\r\n”;
$headers .= ‘Content-Type: text-plain; charset=utf-8’;
$email = filter_input(INPUT_POST, ‘email’, FILTER_VALIDATE_EMAIL);
if($email) {
$headers .= “\r\nReply-To: $email”;
}
$success = mail($to, $subject, $message, $headers -‘[email protected]’);
}
?>
Thank you
Your message hase been sent <?php } else { ?>Oops!
Sorry, there was a problem sending your message <?php } ?> [/php]So the form works in a way, when you type the data it displays the Error message, but it does not make sucessfull sendings, why? What am I doing wrong?
Thank you very much for your help!