Skip to content Skip to sidebar Skip to footer

Submitting Html5 Forms To Email (via Php?)

I'm attempting to create an HTML5 form that submits basic vendor information without opening the user's email client, and with a 'Submitted' (or something of the like) confirmation

Solution 1:

  1. add a method to your form as:

    <form action="" method="post" id="vendorInfo"> //its an example

  2. Give name attribute to your all input filed as:

    <input type="text" name="whatever"> //its an example

then catch these by post method in php

<?phpif(isset($_POST['your_submit_name']))
{
$input_field=$_POST['your_input_field_name'];
$to = "somebody@example.com";
$subject = "your subject";
$message= "Hello mail!". "\r\n";
$message.= $input_field."\r\n";
$headers = "From: webmaster@example.com" . "\r\n" ;
mail($to,$subject,$message,$headers);
?>

Solution 2:

You would need to submit the form to a mailer script on your server (mail.php). Once the server has the form information you can start building the message body there and use the php mail() function to send the message.

To learn about sending mail via php i suggest reading the php docs here: http://www.php.net/manual/en/function.mail.php

You can also format the body of your message with html to have it render nicely in an email client.

You may have to research how to enable send mail via whatever server you'er using. I think by default it is disabled.

Post a Comment for "Submitting Html5 Forms To Email (via Php?)"