How to create a form in a web page with HTML

I want to create a web page in which a form allows the user to insert some personal informations (name surname, phone, etc.) and send them to me in my email box (see http://www.maestripieri.it/mod/contatto).
How is it possible with HTML?
LVL 9
Sar1973Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Andrew DoadesConnect With a Mentor IT TechnicianCommented:
The above will open a new email windows for the user, I have attached some code for a form.html file and a php mailer script, although they look messy they work!

Hope they work for you!
#HTML FILE...
 
<form method="POST" action="mailer.php">
 
          <table border="0" ALIGN="CENTER" cellpadding="5" cellspacing="0" align="center" style="font-family: Tahoma; font-size: 9pt;">
          <tr>
          <td align="left">Your Name:</td>
          <td align="left" valign="middle"><input type="text" name="name" size="35" style='width: 300px;'>
          </td>
          </tr>
          <tr>
          <td  align="left">Your
          Email Address:</font></td>
          <td  align="left" valign="middle"> <input type="text" name="email" size="35" style='width: 300px;'>
          </td>
          </tr>
          <tr>
          <td  align="left">Subject:</font></td>
          <td  align="left" valign="middle"> <input type="text" name="message_subject" size="35" style='width: 300px;'>
          </td>
          </tr>
          <tr>
          <td  align="left" valign="top">Your
          Message:</font></td>
          <td  align="left" valign="top"><textarea name="message" cols="30" rows="8" wrap="VIRTUAL" style='width: 300px;'></textarea>
          </td>
          </tr>
          <tr>
          <td colspan=2 align=center valign=middle><input type="submit" value="Submit" name="submit">
          </td>
          </tr>
          </table>
          </form>
 
#PHP  MAILER SCRIPT
 
<?php
if(isset($_POST['submit'])) {
 
$to = "to@domain.com";
$subject = "Contact from website";
$from = "from@domain.com";
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$message = $_POST['message'];
$message_subject = $_POST['message_subject'];
 
$body = " From: $name_field\n E-Mail: $email_field\n Subject: $message_subject\n Message: $message";
 
echo "Data has been submitted successfully.";
mail($to, $subject, $body);
 
} else {
 
echo "Sending failed, please check all fields";
 
}
?>

Open in new window

0
 
quincydudeCommented:
The easiest way is set the action of the form as your email address like
<form method="post" 
   action="mailto:yourname@yoursite.com" 
     enctype="text/plain">
<input type=text 
   name=your_comments>
<input type=submit 
   value="Submit Your Comments">
</form>

Open in new window

0
 
Sar1973Author Commented:
-
0
All Courses

From novice to tech pro — start learning today.