How Do create enquiry Form ?

Discussion in 'HTML & Website Design' started by foresightseo, Sep 18, 2010.

  1. #1
    How to create an enquiry form in HTML or php and send it to my personnel email-id
     
    foresightseo, Sep 18, 2010 IP
  2. alfa_375

    alfa_375 Active Member

    Messages:
    445
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    60
    #2
    You have to use both, html for creating form and the php to post the form to your email.

    HTML FORM CODE IN THE BODY:
    <form action="send_mail.php" method="post">
    <table>
    <tr>
    <td>Full Name:</td>
    <td>
    <input type="text" name="full_name" value="" maxlength="100" />
    </td>
    </tr>
    <tr>
    <td>Contact Number:</td>
    <td>
    <input type="text" name="contact_number" value="" maxlength="100" />
    </td>
    </tr>
    <tr>
    <td>Email Adress:</td>
    <td>
    <input type="text" name="email_address" value="" maxlength="100" />
    </td>
    </tr>
    <tr>
    <td>Comments:</td>
    <td>
    <textarea rows="10" cols="50" name="comments"></textarea>
    </td>
    </tr>
    <tr><td>&nbsp;</td>
    <td>
    <input type="submit" value="Submit" />
    </td>
    </tr>
    </table>
    </form>

    END OF THE HTML CODE

    PHP SCRIPT CODE:

    <?php

    $webmaster_email = "email@address.com";

    $feedback_page = "index.html";
    $error_page = "index_error.html";
    $thankyou_page = "index_thanks.html";

    $full_name = $_REQUEST['full_name'] ;
    $contact_number = $_REQUEST['contact_number'] ;
    $email_address = $_REQUEST['email_address'] ;
    $comments = $_REQUEST['comments'] ;

    function isInjected($str) {
    $injections = array('(\n+)',
    '(\r+)',
    '(\t+)',
    '(%0A+)',
    '(%0D+)',
    '(%08+)',
    '(%09+)'
    );
    $inject = join('|', $injections);
    $inject = "/$inject/i";
    if(preg_match($inject,$str)) {
    return true;
    }
    else {
    return false;
    }
    }

    if (!isset($_REQUEST['email_address'])) {
    header( "Location: $feedback_page" );
    }

    elseif (empty($email_address) || empty($comments)) {
    header( "Location: $error_page" );
    }

    elseif ( isInjected($email_address) ) {
    header( "Location: $error_page" );
    }

    else {
    mail( $webmaster_email, "Website Feedback Form Results",
    $full_name . "\n" . $contact_number . "\n" . $comments, "From: " . $email_address );
    header( "Location: " . $thankyou_page );
    exit();
    }

    END OF PHP CODE
     
    alfa_375, Sep 18, 2010 IP
  3. NITRO23456

    NITRO23456 Well-Known Member

    Messages:
    516
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    110
    #3
    you need to work a CAPTCHA into that code as well otherwise you are going to be spammed to hell
     
    NITRO23456, Sep 18, 2010 IP
  4. sanhit

    sanhit Peon

    Messages:
    318
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    If still need help u can contact me I can make the same for u :)
     
    sanhit, Sep 22, 2010 IP