I need HTML code for Form to Email. Does anyone has?

Discussion in 'HTML & Website Design' started by over_flow, Oct 12, 2011.

  1. #1
    I have made my new website. I want to include a "Contact Us" form for my website visitors.
    If any visitor of my site want to contact me and He/She put any data in form fields, I want that data to my e-mail's inbox. Thats it..!!!


    Plzzzzzz Help me...!! waiting for your helpful response...!! Thanks!
     

    Attached Files:

    over_flow, Oct 12, 2011 IP
  2. Pixel Image Host

    Pixel Image Host Guest

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    where it says your email here in the contacts.php just add your email there this script is from my image hosting site

    save this as contact.html
    <form method="POST" action="contact.php">
    
    
    <p>Your Name:<br>
    <input type="text" name="YourName">
    <p>Your Email:<br>
    <input type="text" name="YourEmail">
    <p>Your Subject:<br>
    <input type="text" name="YourSubject">
    <p>Your Message:<br>
    <textarea name="YourMessage"></textarea>
    <p>Advertise:<br>
    <input type="checkbox" name="YourAdvertise" value="Yes">
    <p>Other:<br>
    <input type="checkbox" name="YourOther" value="Yes">
    <p><input type="submit" name="submit" value="Submit">
    </form>
    <p>
    
    
    <!-- Contact Form credit link -->
    Created by <a target="_blank" 
    href="http://pixelimagehost.com/">Pixel Image Host</a>
    
    
    </font>
    </center>
    
    
    Code (markup):
    save this as contact.php
    <?php
     
    // get posted data into local variables
    $EmailFrom = "your email here";
    $EmailTo = "your email here";
    $Subject = "Pixel Image Host Contact Us";
    $YourName = Trim(stripslashes($_POST['YourName'])); 
    $YourEmail = Trim(stripslashes($_POST['YourEmail'])); 
    $YourSubject = Trim(stripslashes($_POST['YourSubject'])); 
    $YourMessage = Trim(stripslashes($_POST['YourMessage'])); 
    $YourAdvertise = Trim(stripslashes($_POST['YourAdvertise'])); 
    $YourOther = Trim(stripslashes($_POST['YourOther'])); 
    
    
    // validation
    $validationOK=true;
    if (!$validationOK) {
      print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
      exit;
    }
    
    
    // prepare email body text
    $Body = "";
    $Body .= "YourName: ";
    $Body .= $YourName;
    $Body .= "\n";
    $Body .= "YourEmail: ";
    $Body .= $YourEmail;
    $Body .= "\n";
    $Body .= "YourSubject: ";
    $Body .= $YourSubject;
    $Body .= "\n";
    $Body .= "YourMessage: ";
    $Body .= $YourMessage;
    $Body .= "\n";
    $Body .= "YourAdvertise: ";
    $Body .= $YourAdvertise;
    $Body .= "\n";
    $Body .= "YourOther: ";
    $Body .= $YourOther;
    $Body .= "\n";
    
    
    // send email 
    $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
    
    
    // redirect to success page 
    if ($success){
      print "<meta http-equiv=\"refresh\" content=\"0;URL=ok.htm\">";
    }
    else{
      print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
    }
    ?>
    
    Code (markup):
     
    Pixel Image Host, Oct 12, 2011 IP