Emailing Form

Discussion in 'HTML & Website Design' started by xXMetalicDustXx, Feb 16, 2011.

  1. #1
    I am putting a contact form on a web page, and I want it to send automatically when the user clicks submit. I don't want the mailto action that makes you choose what program or email you want to use..I want it to email it automatically. Is there an action="" that will do that? All I can find is the mailto:


    Thanks!
     
    xXMetalicDustXx, Feb 16, 2011 IP
  2. Dimus

    Dimus Peon

    Messages:
    48
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You going to have to use a server-side scripting language for that, PHP for instance.
    Here is a simple example - www.w3schools.com/PHP/php_mail.asp
     
    Dimus, Feb 16, 2011 IP
  3. GURUSOFIT

    GURUSOFIT Greenhorn

    Messages:
    76
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #3
    <?php

    //Subject and email variables

    $emailsubject = 'Mail From ContactUS Page';
    $webmaster = 'YOUR-EMAIL-HERE';

    // experiment
    //if(isset($_REQUEST['submit'])){

    // gathering data variables

    $title = $_POST['title'];
    $forename = $_POST['forename'];
    $surname = $_POST['surname'];
    $comment = $_POST['comment'];
    $contactpreference = $_POST['ContactPreference'];
    $email = $_POST['email'];
    $phone = $_POST['phone'];
    $post = $_POST['post'];

    $body = <<<EOD
    <b><hr><br>
    Email: $email <br>
    Comments: $comment <br>
    Forename: $forename <br>
    Surname : $surname <br>
    Contact Preference : $contactpreference <br>
    Phone No. : $phone <br>
    Post : $post <br>
    EOD;
    //header( "Location: http://www.example.com/thankyou.html" );


    $headers = "From: $email\r\n";
    $headers .= "Content=type: text/html\r\n";
    $success = mail($webmaster, $emailsubject, $body, $headers);


    // results renders html

    $theResluts = <<<EOD

    /*<html>
    <head>
    <title>Sajh.Co.Uk - Thank you visiting our website.</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <style type="text/css">
    <!--
    body {
    background-color: #f1f1f1;
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 12px;
    font-style: normal;
    line-height: normal;
    font-weight: normal;
    color: #666666;
    text-decoration: none;
    }
    -->
    </style>
    </head>

    <div>
    <div align="left">Thank you for your interest! Your email will be answered very soon!</div>
    </div>
    </body>
    </html>*/
    EOD;
    echo "$theresults";
    header( "Location: http://gurusofit.com/contactus.php?msg:Your+Request+is+Received");
    ?>


    put that code as an action, but if you dont understand on this code send me a mesg i will make a customize version for you
     
    GURUSOFIT, Feb 18, 2011 IP