Page 2 of 2 FirstFirst 12
Results 26 to 36 of 36
  1. #26
    Thanks for this - just used it on one of my sites

  2. #27
    Join Date
    Jun 2006
    Location
    NY
    Posts
    484
    Is there a way to do this with TPL? My site has tpl_load for themes, and i cant find a way to make a contact script otherwise!

  3. #28
    thanks nice tut!

  4. #29
    Join Date
    Aug 2010
    Location
    Somerset, UK
    Posts
    53

    Talking

    Definitely would recommend using capcha with all contact us forms to prevent unnecessary spam.

    Also another clever trick to be used alongside form validation is to create a simple CSS rule to make a textarea's background colour change when field is wrong / blank...

    Something like this:
    PHP Code:
    .error textarea {
    background-colorred;

    Then within your PHP page, add a little something to the form element you are checking against like this:
    PHP Code:
    <textarea name="comments" <?php if($_POST[comments] == ""){ echo "class=\"error\""?>></textarea>
    This should change the background colour to red if the field is submitted as blank, simple and handy. If you are going to be using it regularly then would be worth writing a PHP function and just call it every time a form is used checking for set names such as 'email', this way you can also use regular expressions to check email is valid all in 1.

  5. #30
    Thanks for the form tutorial but it would be appreciated if you can add captcha code too for security.


    Quote Originally Posted by YouHostMe[Julie] View Post
    This is a simple script to put a contact form on your website

    Add this code to your site (This is the form)

    Code:
    <form method="POST" action="send.php">
    Fields marked (*) are required
    
    <p>Email From:* <br>
    <input type="text" name="EmailFrom">
    <p>Full Name:* <br>
    <input type="text" name="Name">
    <p>Comments:* <br>
    <input type="text" name="Comments">
    <p><input type="submit" name="submit" value="Submit">
    </form>
    <p>
    Then create a file called send.php with the following

    Code:
    <?php 
    $EmailFrom = Trim(stripslashes($_POST['EmailFrom'])); 
    $EmailTo = "yourname@youraddress.com";
    $Subject = "Contact Form Results";
    $Name = Trim(stripslashes($_POST['Name'])); 
    $Comments = Trim(stripslashes($_POST['Comments'])); 
    
    // validation
    $validationOK=true;
    if (Trim($EmailFrom)=="") $validationOK=false;
    if (Trim($Name)=="") $validationOK=false;
    if (Trim($Comments)=="") $validationOK=false;
    if (!$validationOK) {
      print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
      exit;
    }
    
    // prepare email body text
    $Body = "";
    $Body .= "Name: ";
    $Body .= $Name;
    $Body .= "\n";
    $Body .= "Email: ";
    $Body .= $EmailFrom;
    $Body .= "\n";
    $Body .= "Comments: ";
    $Body .= $Comments;
    $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.html\">";
    }
    else{
      print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">";
    }
    ?>
    Create 2 pages for your error and success pages, and name them error.html and ok.html

    Hope that helps a few people

  6. #31

    Simple PHP Contact Form

    Hi everyone,

    From the scripts Ive seen online, it seems that there is only a way to create a PHP form that will send an e-mail to a specified e-mail address that is within the PHP script itself. Is there a way to create a mailing script that will, for example, send an HTML e-mail to the customers e-mail address thats entered into the form instead? Or, does this require additional coding language to do this?

    Thanks for any tips/assistance

  7. #32
    Join Date
    Feb 2013
    Location
    Georgetown, TX
    Posts
    16
    Yes you can send to a specified address you would want to put an html input for the email and call the variable that you create in the form using GET or POST and just substitute the email for the variable for most of the simple ones. It depends a lot on the original code as to how best to implement it, but the method above is pretty standard.

    Do you have a particular code/script that you are currently trying to use?

  8. #33
    Join Date
    Feb 2013
    Location
    Georgetown, TX
    Posts
    16
    Wow... I just realized I thought this was an OP but it's on the third page... time to go to sleep. Sorry about that. :-\

  9. #34
    Join Date
    Jun 2012
    Posts
    315
    Quote Originally Posted by Invemnmen View Post
    Hi everyone,

    From the scripts Ive seen online, it seems that there is only a way to create a PHP form that will send an e-mail to a specified e-mail address that is within the PHP script itself. Is there a way to create a mailing script that will, for example, send an HTML e-mail to the customers e-mail address thats entered into the form instead? Or, does this require additional coding language to do this?

    Thanks for any tips/assistance
    Sure you need to set up a variable, sanitize it, and have it used in the output of where to send the email.

    If anyone is reading this post... DO NOT USE THIS SCRIPT... it isn't very secure. None of the inputs are validated. You are better of purchasing a contact form script from http://codecanyon.net for $5.

  10. #35
    Join Date
    Nov 2006
    Location
    Karachi, Pakistan
    Posts
    1,349
    Quote Originally Posted by amchost View Post
    I find this to be a great - and stable - mail script if that helps anybody.

    In case anyone was wondering, I did not write this script, so full credit goes to the original creator
    It's terrible! A spam magnet. Name isn't sanitized so anyone can enter additional headers and send messages to literally thousands of people using this contact form. Do NOT use it!
    WordPress Whois - Domain name lookup plugin for WordPress

  11. #36
    Join Date
    Feb 2012
    Location
    United Kingdom
    Posts
    13
    Thanks for the tut and code samples, should be very easy to integrate into a DB or FlatFile for 'archives'.

  12. Newsletters

    Subscribe Now & Get The WHT Quick Start Guide!

Page 2 of 2 FirstFirst 12

Related Posts from theWHIR.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •