1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Anyone have a quick "Contact Us" form code?

Discussion in 'Web Design' started by Jcsarokin, Dec 27, 2009.

  1. Jcsarokin

    Jcsarokin Power Member

    Joined:
    Mar 2, 2009
    Messages:
    718
    Likes Received:
    1,015
    Location:
    Los Angeles / Beverly Hills
    Been Googling it for a bit and they all want me to sign up to their bullshit site and spam me (always read the privacy policy :cool:).

    Anyone here have some quick code for a contact us form lying around?

    Name
    Email
    Subject
    (website optional)
    Body

    or something to that extent.

    Id really appreciate it (+Rep)
     
  2. cyklotrial

    cyklotrial Regular Member

    Joined:
    Oct 13, 2008
    Messages:
    248
    Likes Received:
    82
    Location:
    Wonderland
    PHP:
    <?php
    if (empty($_POST['submit'])) {
        echo 
    "<table border=\"0\"><form method=\"post\">
    <tr>
    <td>Body:</td>
    <td><textarea name=\"body\" style=\"width: 250px; height: 100px\"></textarea></td>
    </tr>
    <tr>
    <td>Name:</td>
    <td><input type=\"text\" name=\"name\" style=\"width: 250px\"></td>
    </tr>
    <tr>
    <td>e-mail</td>
    <td><input type=\"text\" name=\"email\" style=\"width: 250px\"></td>
    </tr>
    <tr>
    <td>e-mail</td>
    <td><input type=\"text\" name=\"subject\" style=\"width: 250px\"></td>
    </tr>
    <tr>
    <td> </td>
    <td><input type=\"submit\" name=\"submit\" value=\"Send\"> 
    <input type=\"reset\" value=\"Od nowa\"></td></form>
    </tr>
    </table>"
    ;
    }

    elseif (!empty(
    $_POST['body']) && !empty($_POST['name']) && !empty($_POST['email']) && !empty($_POST['subject'])) {

        
    $message $_POST['body'];
          
    $subject $_POST['subject'];
        
    $header "From: $_POST[name] <$_POST[email]>";

        @
    mail("yourmail@domain.com","$subject","$message","$header")
        or die(
    'Error');
        
        echo 
    "<div align=\"center\"><strong>Success!</strong></div>";
    }

    else echo 
    "<span style=\"color: #FF0000; text-align: center;\">Error!</span>";

    ?> 
     
    • Thanks Thanks x 1