simple email form

Posted on 2005-04-28
Last Modified: 2008-03-06
Can you guys give me a simple email form with name, email, comments, clear button,and submit button.

Also, I would like it to use the "Location" command to send the email to

Thanks in advanced,

{ Removed by Diablo84 - PHP Page Editor }
Question by:weikelbob
    LVL 7

    Assisted Solution

    <form method=post name=frm1 action=?>
    <input type=text name=name value="">
    <input type=text name=email value="">
    <input type=text name=comments value="">
    <input type=Reset name=name value="Submit!">
    <input type=Submit name=name value="Clear!">
    if ($_POST) {
       $m = "New email:\n\n";
       foreach($_POST as $k=>$v) {
           $m.="$k : $v\n";
    mail ("","New Form Submission!",$m);

    Accepted Solution


    $to = "";

    if (isset($_POST['message']))
      $message = $_POST['message'];
      $from = $_POST['from'];
      $fromemail = $_POST['fromemail'];
      $headers = 'From: ' . $from . ' <' . $fromemail . ">\r\n";
      $headers .= 'Reply-To: <' . $fromemail . ">\r\n";
      $headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";

      mail($to, "Form submitted from your website", $message,$header);


    <form method=post action="<? echo "$PHP_SELF"; ?>">
    <b>Your name:</b><br>
    <input type="text" name="from" size="27">

    <b>Your Email:</b><br>
    <input type="text" name="fromemail" size="27">

    <b>Please add any comments you have below:</b>
    <textarea cols="40" rows="10" name="message"></textarea>

    <input type="submit" value="Send">
    <input type="reset" value="Clear the form">

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Suggested Solutions

    Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
    Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
    The viewer will learn how to count occurrences of each item in an array.
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now