1. This website uses cookies. By continuing to use this website you are giving consent to cookies being used.
    For information on cookies and how you can disable them visit our Cookie Usage page.
    Dismiss Notice

PHP Any free PHP contact form?

Discussion in 'Web Development' started by flek, Jan 9, 2010.

  1. flek

    flek Banned

    Hello guys,

    can anybody help me to get a free php contact form?

    Thank you very much.
     
  2. Jiggles

    Jiggles Member

    contact_form.gif
    contact_form_view.gif
    Simple yet effective.
     
    1 person likes this.
  3. Olaf

    Olaf New Member

    Yesterday I finished a tutorial on how-to create one using jquery, PHP and SMTP:
    check my blog web-development-blog.com (entry from 12 jan 2010)
     
  4. ishkey

    ishkey Moderator, Logos, Sports Crests Staff Member Verified Member

    Such a great Tutorial by helpimadj -it had to become a Sticky Post.
    Thanks for taking the time to place a graphic in it, that really helps following along.
    I know others will really find your work useful.
     
  5. Jiggles

    Jiggles Member

    No problem ishkey. I'm sure I could do some more if people wanted me to.
     
  6. rdenheijer

    rdenheijer New Member

    hi there all

    am trying to find a template for filling a complete contact forum with an attache space like when someone attache a document now when he/she fills it in completely presses submit stored in a databse the database generates
    an email or link to obtaine the filled in forum to give an example pls go to www2.degruijterwens.nl now you see an forum but i dont get the rest i hope someone can help me with it
     
  7. flek

    flek Banned

    Hey helpimadj,

    thanks man!! I tried it out already.. :( But the coming emails doesn't carry the details. Just coming as invisible emails.

    Flek..!!
     
  8. unbase

    unbase Guest

    Try This...


    @flek (& others),

    Try this, a spam-less contact form that'll let you send the reply emails to 2 different email recieving addresses. I use this exclusively anytime I need a contact form or I do a videosqueeze page and want to hook the form up to my admin addy and auto responder;

    PHP:
    <?php 
    if (isset($_POST["op"]) && ($_POST["op"]=="send")) { 
    /******** START OF CONFIG SECTION *******/
      
    $sendto  "Your Email Address 1";
      
    $sendto2  "Your Email Address 2";
      
    $subject "Website Contact Enquiry";
    // Select if you want to check form for standard spam text
      
    $SpamCheck "Y"// Y or N
      
    $SpamReplaceText "<font color='00CCFF'>*content removed*</font>";
    // Error message prited if spam form attack found
    $SpamErrorMessage "<p align=\"center\"><font color=\"red\">Malicious code content detected.
    </font><font color='00CCFF'><br><b>Your IP Number of <b>"
    .getenv("REMOTE_ADDR")."</b> has been logged.</b></p></font>";
    /******** END OF CONFIG SECTION *******/
     
      
    $name $HTTP_POST_VARS['name']; 
      
    $email $HTTP_POST_VARS['email']; 
      
    $message $HTTP_POST_VARS['message']; 
      
    $headers "From: $email\n";
      
    $headers "MIME-Version: 1.0\n"
         
    "Content-Transfer-Encoding: 7bit\n"
         
    "Content-type: text/html;  charset = \"iso-8859-1\";\n\n";
    if (
    $SpamCheck == "Y") {     
    // Check for Website URL's in the form input boxes as if we block website URLs from the form,
    // then this will stop the spammers wastignt ime sending emails
    if (preg_match("/http/i""$name")) {echo "$SpamErrorMessage"; exit();} 
    if (
    preg_match("/http/i""$email")) {echo "$SpamErrorMessage"; exit();} 
    if (
    preg_match("/http/i""$message")) {echo "$SpamErrorMessage"; exit();} 
    // Patterm match search to strip out the invalid charcaters, this prevents the mail injection spammer 
      
    $pattern '/(;|\||`|>|<|&|^|"|'."\n|\r|'".'|{|}|[|]|\)|\()/i'// build the pattern match string 
     
      
    $name preg_replace($pattern""$name); 
      
    $email preg_replace($pattern""$email); 
      
    $message preg_replace($pattern""$message); 
    // Check for the injected headers from the spammer attempt 
    // This will replace the injection attempt text with the string you have set in the above config section
      
    $find = array("/bcc\:/i","/Content\-Type\:/i","/cc\:/i","/to\:/i"); 
      
    $email preg_replace($find"$SpamReplaceText"$email); 
      
    $name preg_replace($find"$SpamReplaceText"$name); 
      
    $message preg_replace($find"$SpamReplaceText"$message); 
     
    // Check to see if the fields contain any content we want to ban
     
    if(stristr($name$SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();} 
     if(
    stristr($message$SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();} 
     
     
    // Do a check on the send email and subject text
     
    if(stristr($sendto$SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();} 
     if(
    stristr($subject$SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();} 
    }
    // Build the email body text
      
    $emailcontent 
    ----------------------------------------------------------------------------- 
       WEBSITE CONTACT ENQUIRY
    ----------------------------------------------------------------------------- 
    Name: 
    $name 
    Email: 
    $email 
    Message: 
    $message 
    _______________________________________ 
    End of Email 
    "

    // Check the email address enmtered matches the standard email address format
     
    if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,6}$"$email)) { 
      echo 
    "<font color='00CCFF'><p>It appears you entered an invalid email address</p><p><a href='javascript: history.go(-1)'>Click here to go back</a>.</p></font>"

     elseif (!
    trim($name)) { 
      echo 
    "<font color='00CCFF'><p>Please go back and enter a Name</p><p><a href='javascript: history.go(-1)'>Click here to go back</a>.</p></font>"

     
     elseif (!
    trim($message)) { 
      echo 
    "<font color='00CCFF'><p>Please go back and type a Message</p><p><a href='javascript: history.go(-1)'>Click here to go back</a>.</font></p>"
    }  
     elseif (!
    trim($email)) { 
      echo 
    "<font color='00CCFF'><p>Please go back and enter an Email</p><p><a href='javascript: history.go(-1)'>Click here to go back</a>.</font></p>"

    // Sends out the email or will output the error message 
     
    elseif (mail($sendto$subject$emailcontent$headers)) { 
      echo 
    "<font color='00CCFF'><br><br><p><b>Thank You $name</b></p><p>Your enquiry is noted!</font></p>"


    else { 
    ?>
                    <br>
                    <font color="#0000FF">Please complete all details of your contact<br>
                    and you'll be notified A.S.A.P. (via email).</font><br>
    <form action="#" method="post"><INPUT NAME="op" TYPE="hidden" VALUE="send"> 
      <table> 
        <tr> 
          <td><p><font color="#0000FF">Name:</font></p></td> 
          <td> 
            <input name="name" type="text" size="30" maxlength="150"> 
          </td> 
        </tr> 
          <tr> 
          <td><p><font color="#0000FF">E-mail:</font></p></td> 
          <td> 
            <input name="email" type="text" size="30" maxlength="150"> 
          </td> 
        </tr> 
        <tr> 
          <td valign="top"><p><font color="#0000FF">Message:</font></p></td> 
          <td><textarea name="message" cols="40" rows="6"></textarea></td> 
        </tr> 
        <tr><td></td> <td><input name="submit" type="submit" value="Send Message"></td></tr> 
      </table> 
    </form>
                    <?php ?>
                  </td>
      </tr>
    </table>
          <br>
          <div align="center">[&copy; 2010 * YOUR COMPANY]</div>
        </div>
    See if this doesn't clear up your contact form problems.
     
  9. flek

    flek Banned

    @ thank you very much!!

    But I could see another free resource, which works perfectly! :)

    File - lite_process.php

    File lite_settings.php
    file - lite_styles.css

    File - lite_validation.js

     
  10. flek

    flek Banned

    Open the file 'lite_settings.php' using a code/plain text Editor.

    The file will look like this: -

    <?php

    $email_to = "youremailaddress@yourdomain.com"; // your email address
    $email_subject = "Contact Form Message"; // email subject line
    $thankyou = "thankyou.htm"; // thank you page

    ?>

    Enter your email address in replace of youremailaddress@yourdomain.com

    Change the email subject (if you like)

    Change your thank you page reference (if you like)

    Save the file.



    Copy ALL files onto your website using an FTP program (filezilla for example)


    Copy the HTML from contactform.htm and paste it into your existing page.

    File - contactform.htm

    Note: This files are installed and working perfectly without any problems.

    The contact us page created by this files: Contact Us
    Thank you page created for this: Thank you!

    In case if you need the ready-made ready-to-upload files just give me ping.
     
  11. hugardo

    hugardo New Member

    I am having the same issue, the subject line is coming thu fine becuase I just place a text on it, but all I get is an email with "from" nothing else, please help!
     
  12. Jiggles

    Jiggles Member

    Which script are you using?
     
  13. hugardo

    hugardo New Member

    The one you posted.
     
  14. Jiggles

    Jiggles Member

    Right here is my new and improved form:

    Contact.html

    PHP:

    <table width="400" border="0" align="center" cellpadding="3" cellspacing="1">
    <
    tr>
    <
    td><strong>Contact Form </strong></td>
    </
    tr>
    </
    table>

    <
    table width="400" border="0" align="center" cellpadding="0" cellspacing="1">
    <
    tr>
    <
    td><form name="form1" method="post" action="php.php"> <input name="pong" type="hidden" value="ping" />
    <
    table width="100%" border="0" cellspacing="1" cellpadding="3">
    <
    tr>
    <
    td width="16%">Subject</td>
    <
    td width="2%">:</td>
    <
    td width="82%"><input name="subject" type="text" id="subject" size="50"></td>
    </
    tr>
    <
    tr>
    <
    td>Detail</td>
    <
    td>:</td>
    <
    td><textarea name="message" cols="50" rows="4" id="detail"></textarea></td>
    </
    tr>
    <
    tr>
    <
    td>Name</td>
    <
    td>:</td>
    <
    td><input name="name" type="text" id="name" size="50"></td>
    </
    tr>
    <
    tr>
    <
    td>Email</td>
    <
    td>:</td>
    <
    td><input name="email" type="text" id="customer_mail" size="50"></td>
    </
    tr>
    <
    tr>
    <
    td>&nbsp;</td>
    <
    td>&nbsp;</td>
    <
    td><input type="submit" name="Submit" value="Submit"> <input type="reset" name="Submit2" value="Reset"></td>
    </
    tr>
    </
    table>
    </
    form>
    </
    td>
    </
    tr>
    </
    table>
    php.php

    PHP:
    <?php
    //Form validation. Was the infomation sent from our form?
    $pong $_POST['pong'];
     
    //Email Subject
    $subject $_POST['subject'];

    //Message Details
    $message_form $_POST['message'];

    //Email address of sender
    $email $_POST['email'];

    if (
    preg_match("/[\r\n]/",$email)) {
        die(
    'ERROR No sending spam now!');
    }

    //Sender name
    $name $_POST['name'];

    if (
    $pong == 'ping') { //The form validaton. Makes sure that the form came from our contact form.
        
    //Email address to send form to
    $to_email 'example@example.co.uk';

    //Header Infomation
    $header "From: $name <$email>";

    //Message Body
    $message "$name$message_form$email";

    //Email the script
    $send_email mail($to_email,$subject,$message,$header);

    //Check if email has sent else display error.
    if ($send_email) {
        echo 
    'WE have receved your message.';
    }
    else {
        echo 
    'ERROR!';
    }
    }
    else {
        echo 
    'Access denied. Please use the form from our site.';
    }
    ?>
    Hope this helps :)

    Will post images when I get the time too.
     
  15. hersheyphoto

    hersheyphoto New Member

    Changing "SUBMIT" Button For Form

    @umlautbastards Hello! Your post was very helpful. I'm a photographer and do some GD work for business. I'm currently working to update my website to PHP coding and it sometimes is a little over my head :(

    I was able to edit in all the appropriate information specific to my site, however I designed a button for "submit request" in photoshop, and not sure what order/how the code should read. The things I have been try seem to be inserting my created button with the code that seems to implicate the "submit" action — but also changing that text that appears in the original button which came with the coding template and I cannot get rid of.

    What I have currently:

    <tr><td></td> <td><img src="images/txt_contact_ button.jpg" width="300" height="100" /><input name="submit" type="submit" value=images/txt_contact_ button.jpg" width="300" height="100"" /></td></tr>

    Any news on how I should be combining these so that the button.jpg becomes the submit button for the forms!???!?![​IMG]


     
  16. Jiggles

    Jiggles Member

    Hi People,

    Here is a new and improved contact form that only needs one page! I need the recaptcha keys and recaptchalib.php file to work but they are easy to get just go to: reCAPTCHA: Stop Spam, Read Books and get them.

    Enjoy!

    PHP:
    <?php
    //Go to: www.recaptcha.net to get the keys to enter bellow and to download the recaptchalib.php file. 
    /*************** reCAPTCHA KEYS****************/
    $publickey "PUBLIC KEY";
    $privatekey "PRIVATE KEY";

    $err = array();
    $msg = array();

    if(
    $_POST['submit'] == 'Submit'

    function 
    filter($data) {
        
    $data trim(htmlentities(strip_tags($data)));
        
        if (
    get_magic_quotes_gpc())
            
    $data stripslashes($data);
        
        
        return 
    $data;
    }

    function 
    isEmail($email){
      return 
    preg_match('/^\S+@[\w\d.-]{2,}\.[\w]{2,6}$/iU'$email) ? TRUE FALSE;
    }

    /******************* Filtering/Sanitizing Input *****************************
    This code filters harmful script code and escapes data of all POST data
    from the user submitted form.
    *****************************************************************/
    foreach($_POST as $key => $value) {
        
    $data[$key] = filter($value);
    }

    /********************* RECAPTCHA CHECK *******************************
    This code checks and validates recaptcha
    ****************************************************************/
     
    require_once('recaptchalib.php');
         
          
    $resp recaptcha_check_answer ($privatekey,
                                          
    $_SERVER["REMOTE_ADDR"],
                                          
    $_POST["recaptcha_challenge_field"],
                                          
    $_POST["recaptcha_response_field"]);

          if (!
    $resp->is_valid) {
            die (
    "<h3>Image Verification failed!. Go back and try again.</h3>" .
                 
    "(reCAPTCHA said: " $resp->error ")");            
          }
          
          
    //Subject
    if(!isEmail($data['email'])) {
    $err[] = "ERROR - Invalid email address.";
    }
    if(empty(
    $err)) {
    $subject $data['subject'];

    // message
    $message '
    <html>
    <body>
    <p><strong>Subject:</strong> '
    .$data['subject'].' </p>

    <p><strong>There message:</strong> '
    .$data['message'].'</p>

    <p>'
    .$data['name'].'</p>
       
    </body>
    </html>
    '
    ;

    // To send HTML mail, the Content-type header must be set
    $headers  'MIME-Version: 1.0' "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' "\r\n";

    // Additional headers
    $headers .= 'To:  Your name <your@email.com>' "\r\n";
    $headers .= 'From:'.$data['name'].'<'.$data['email'].'>' "\r\n";


    // Mail it
    mail($to$subject$message$headers);

    $msg[] = "Your message has been sent.";
    }
    }
    ?>
    <html>
    <head> 
    <title>Contact Us</title>
    <style type="text/css">

    .msg {
    padding: 5px;
    width: 500px;
    margin: 2px;
    font: bold 13px  verdana;
    color: #33cc00;
    border: 1px solid #33cc00;
    background-color: #D6FEDC;

    .error {
    padding: 5px;
    width: 500px;
    margin: 2px;
    font: bold 13px  verdana;
    border: 1px solid #c00;
    color: #c00;
    background-color: #FEF1ED;
    }

    </style>
    </head>
    <body>

                                <?php
                                
    if(!empty($err))  {
           echo 
    "<div class=\"error\">";
          foreach (
    $err as $e) {
            echo 
    "* Error - $e <br>";
            }
          echo 
    "</div>";    
           }
           if(!empty(
    $msg))  {
            echo 
    "<div class=\"msg\">" $msg[0] . "</div>";

           }
           
    ?>

    <form action="contact.php" method="post">
    <p>Your Name: <input name="name" type="text" /></p>
    <p>Subject: <input name="subject" type="text" /></p>
    <p>Your Email: <input name="email" type="text" /></p>
    <p>Your message: <textarea name="message" cols="" rows=""></textarea></p>
    <p>Are you human?</p>
    <?php 
                
    require_once('recaptchalib.php');
                
                    echo 
    recaptcha_get_html($publickey);
                
    ?>
    <input name="submit" type="submit" value="Submit" />

    </form>                    

    </body>
    </html>
     
  17. 2012ersd

    2012ersd New Member

    Hi,

    Who to create a webpage database?
    What are the steps for building it?

    Thanks,
     
  18. unbase

    unbase Guest

    Thanx, jiggles!

    @jiggles, thanx SO MUCH for that revised output of yours. Intending to implement it in an HTML5 site I'm devving in a few wks. Always up to trying something new, and your coding looks quite sturdy and up to
    hi-volume usage.

    @hersheyphoto, maybe I'm not understanding exactly where you're
    getting stuck? Your issue with the submit button should, in my
    experience, be a simple matter of just HTML'ing in a preset image
    that the button code should wrap around. If this is a case of behavior
    of the input once initialized, you'll have to either PM me here or
    we can agree to a mutual IM. In which case PLEASE don't be
    hesitant to PM me. I HOPE I can help you.:eek:
     
  19. dunkoo

    dunkoo New Member

    Hi jiggle, thanx for the sharing. However, I'd encounter some problem at the email sending part. Once I click the submit button, it will link to the php.php codes instead of sending the form to my email. May I know what's wrong with it? Thank you so much.
     
  20. Jiggles

    Jiggles Member


    Use this script in a PHP file called contact.php and upload it to a PHP enabled server. This form only uses the one page that calls its self meaning less files! That should fix your issues: