A simple snippet posted here as a note and for all those who are looking with the form submit example. A very simple example that demontrates on creating a form with a submit and action.

The snippet would get the data submitted by a user using the form and will send an email to the admin.

First let’s create a page with the form ,let’s name it as our index.html.




<!–this is just a simple page ,no style is created –>

<form id="email_form" method="POST" action="sendmail.php">

<input type="text" name="name" size="20"/>

<input type="text" name="email" size="20"/>

<textarea name="message"></textarea>





If you noticed on the code above, the form looks for sendmail.php so we will create sendmail.php for our form. It should be located where the index.html for this example.






$headers  = ‘MIME-Version: 1.0’ . "rn";

$headers .= ‘Content-type: text/html; charset=iso-8859-1’ . "rn";

$headers .= ‘From: ‘ . $name . ‘<‘.$email . ‘>’ .  "rn";

$to = "xmeappxxxx@yahoo.com";

$subject = "Contact Form";

mail($to, $subject, $message,$headers);

header(‘Location: /index2.html’);



So that’s it.

If you have question just post below and give some comments.

The code above is not tested but it should work.