WEB form question

Discussion in 'OT Technology' started by nashstradamus, Apr 3, 2009.

  1. nashstradamus

    nashstradamus New Member

    Joined:
    Nov 2, 2003
    Messages:
    899
    Likes Received:
    0
    Location:
    East Coast, USA
    here the code for a form on a static html page

    <form id="contactForm" action="/" method="post">

    <fieldset><legend>Contact form</legend>
    <p>
    <label for="name">Name</label>
    <input type="text" name="name" id="name" size="30" />
    </p>
    <p>
    <label for="email">Email</label>
    <input type="text" name="email" id="email" size="30" />
    </p>
    <p>
    <label for="message">Message</label>
    <textarea name="comment" id="comment" rows="10" cols="30"></textarea>
    </p>
    <p class="submit">
    <button type="submit">Send</button>
    </p>
    </fieldset>

    </form>


    what do i need to do to make it submit to an email address?
     
  2. Ricky

    Ricky █▄ █▄█ █▄ ▀█▄

    Joined:
    Jun 17, 2005
    Messages:
    38,767
    Likes Received:
    6
    php
     
  3. Ricky

    Ricky █▄ █▄█ █▄ ▀█▄

    Joined:
    Jun 17, 2005
    Messages:
    38,767
    Likes Received:
    6
    It's very simply.

    The html only covers the layout. The php covers the backend and all the actual work. Here's a simple script that should work

    Code:
    <?php
    
    $Name = $_REQUEST['name']; //senders name
    $email = $_REQUEST['email']; //senders e-mail adress
    $recipient = "[email protected]"; //recipient
    $mail_body = $_REQUEST['comment']; //mail body
    $subject = "Subject for reviever"; //subject
    $header = "From: ". $Name . " <" . $email . ">\r\n"; //optional headerfields
    
    mail($recipient, $subject, $mail_body, $header); //mail command :)
    ?>
    
    Name that mail.php or something and in your html put the action to mail.php instead of /
     
  4. SmugZombie

    SmugZombie OT Supporter

    Joined:
    Aug 2, 2006
    Messages:
    3,783
    Likes Received:
    0
    Location:
    Purgatory
    Then have that page display a "thank you for submitting" or have it redirect you to a thanks.html or something...
     
  5. SmugZombie

    SmugZombie OT Supporter

    Joined:
    Aug 2, 2006
    Messages:
    3,783
    Likes Received:
    0
    Location:
    Purgatory
    :mamoru:
     

Share This Page