Question:

HTML HELP? How to send form by e-mail??

by  |  earlier

0 LIKES UnLike

All I know is basic HTML and CSS. I am making a simple contact us form but how in the world can I make it so that when the user fills out everything, and clicks the submit button, the form gets sent to an e-mail address I specified?? I don't want to do mailto:someone@somewhere.com because that opens your e-mail. I just need the user to click submit and thats it, like all the other forms on the internet.

Please explain clearly how I can do this. I need this URGENT! Thanks.

 Tags:

   Report

4 ANSWERS


  1. Couple of ways. The PHP Mail Function has already been described.

    The other method is using a CGI script. Most servers already have them put together, you simply need to find them, and follow the instructions on using them. If your server does NOT provide a CGI Form Mailer in their package, you can write one all by yourself. It really isn't as difficult as you might imagine. Full instructions can be found here:

    http://www.elated.com/articles/writing-a...

    That one is all you would need...simple and easy to use.


  2. You need to use the PHP mail function. PHP is a server-side language, which means not all web hosts come with PHP installed.

    Find a web host that offers PHP, and make a new file called send.php.

    Put this in it:

    <?php

    $to = "someone@example.com";

    $subject = "Test mail";

    $message = "Hello! This is a simple email message.";

    $from = "someonelse@example.com";

    $headers = "From: $from";

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

    echo "Mail Sent.";

    ?>

    Save it, then make a new file called mail.html:

    <html>

    <body>

    <?php

    if (isset($_REQUEST['email']))

    //if "email" is filled out, send email

      {

      //send email

      $email = $_REQUEST['email'] ;

      $subject = $_REQUEST['subject'] ;

      $message = $_REQUEST['message'] ;

      mail( "someone@example.com", "Subject: $subject",

      $message, "From: $email" );

      echo "Thank you for using our mail form";

      }

    else

    //if "email" is not filled out, display the form

      {

      echo "<form method='post' action='mailform.php'>

      Email: <input name='email' type='text' />

      Subject: <input name='subject' type='text' />

      Message:

      <textarea name='message' rows='15' cols='40'>

      </textarea>

      <input type='submit' />

      </form>";

      }

    ?>

    </body>

    </html>

    Save that, then view mail.html. This should send to someone@example.com (or whatever you changed it to).

  3. Here is another low tech resource for you. Maybe not the best solution, but you can try it.

    http://www.w3schools.com/html/tryit.asp?...

  4. I did this mail form for class. You would change the method to method="get" and action="email@yahoo.com" for example. Change the fields to whatever you want.

    <form id="form1" name="form1" method="post" action="register1.php">

      

      <div align="center">

        <table width="74%" border="1">

          <tr>

            <td width="34%" valign="top"><div align="left">FULL NAME:</div></td>

            <td width="66%" valign="top"><label>

              <div align="right">

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

                </div>

            </label></td>

          </tr>

          <tr>

            <td valign="top"><div align="left">STREET ADDRESS: </div></td>

            <td valign="top"><label>

              <div align="right">

                <input type="text" name="address" />

                </div>

            </label></td>

          </tr>

          <tr>

            <td valign="top"><div align="left">CITY:</div></td>

            <td valign="top"><label>

              <div align="right">

                <input type="text" name="city" />

                </div>

            </label></td>

          </tr>

          <tr>

            <td valign="top"><div align="left">STATE/PROVINCE:</div></td>

            <td valign="top"><label>

              <div align="right">

                <input type="text" name="state" />

                </div>

            </label></td>

          </tr>

          <tr>

            <td valign="top"><div align="left">COUNTRY:</div></td>

            <td valign="top"><label>

              <div align="right">

                <input type="text" name="country" />

                </div>

            </label></td>

          </tr>

          <tr>

            <td valign="top"><div align="left">ZIP/POSTAL CODE: </div></td>

            <td valign="top"><label>

              <div align="right">

                <input type="text" name="zip" />

                </div>

            </label></td>

          </tr>

          <tr>

            <td valign="top"><div align="left">FULL PHONE NUMBER: </div></td>

            <td valign="top"><label>

              <div align="right">

                <input type="text" name="phone" />

                </div>

            </label></td>

          </tr>

          <tr>

            <td valign="top"><div align="left">SERVICES REQUESTED: </div></td>

            <td valign="top"><label>

              <div align="right">

                <input type="text" name="service" />

                </div>

            </label></td>

          </tr>

          <tr>

            <td valign="top"><div align="left">OTHER: </div></td>

            <td valign="top"><label>

              <div align="right">

                <input type="text" name="other">

              </div>

            </label></td>

          </tr>

        </table>

      </div>

      <p align="center"><input name="Register" type="submit" id="Register" value="Register" />

        <input type="reset" name="Reset" value="Reset" /></p>

    </form>

    Other sources:

    http://www.mycontactform.com/

    http://www.response-o-matic.com/

    www.emailmeform.com

Question Stats

Latest activity: earlier.
This question has 4 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.