Send email with php from html form on submit with the same script
What I want to do is send an email when a user has finished filling in a
form and then using the same info entered by the user to send the mail. I
want to do it from the same script that displays the web page that has the
form.
What I have is a php script that will display a simple page with a form,
the form has a submit button, when the user clicks that submit button,
using the info that the user entered in the input
fields(email,subject,message) i would like to send the email from the same
script. Is that even possible? If it is, how?
I found some snippet like this, but it unfortunately does not work:
<?php
if(isset($_POST['submit'])){
$to = $_POST['email'];
$subject = $_POST['name'];
$message = echo getRequestURI();
$from = "zenphoto@example.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
}
?>
No comments:
Post a Comment