Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Nice Simple Contact Form

  • This topic is empty.
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #23976
    JennW
    Member

    Hi. I’ve downloaded the "Nice Simple Contact Form" and made all the needed adjustments. It is working properly (what a great form! :D ) but when I tested it, the email states that it’s from [email protected].

    I see where it states this in the .php :
    $EmailFrom = "[email protected]";

    but what do I change it to make the email say who actually sent it?

    Thanks!
    JennW

    #53182

    I believe this is the code you started with in "contactengine.php":

    Code:
    // CHANGE THE VARIABLES BELOW

    $EmailFrom = “[email protected]”;
    $EmailTo = “[email protected]”;
    $Subject = “Contact Form Submission”;

    $Name = Trim(stripslashes($_POST[‘Name’]));
    $Tel = Trim(stripslashes($_POST[‘Tel’]));
    $Email = Trim(stripslashes($_POST[‘Email’]));
    $Message = Trim(stripslashes($_POST[‘Message’]));

    You could move the "emailFrom" line down below the lines where PHP gets the form values, and use the visitors email address:

    Code:
    // CHANGE THE VARIABLES BELOW

    $EmailFrom = “[email protected]”;
    $Subject = “Contact Form Submission”;

    $Name = Trim(stripslashes($_POST[‘Name’]));
    $Tel = Trim(stripslashes($_POST[‘Tel’]));
    $Email = Trim(stripslashes($_POST[‘Email’]));
    $Message = Trim(stripslashes($_POST[‘Message’]));

    $EmailTo = $Email;

    #53192
    JennW
    Member

    That worked!

    Changed :
    $EmailFrom = "[email protected]";
    to :
    $EmailFrom = $Email;

    – and moved it under the $Message line (but I’m not sure that matters with the above change in place)

    I also changed :
    $Subject = "Online Contact";
    to :
    $Subject = $Subject;

    and added the following :
    $Body .= "Subject: ";
    $Body .= $Subject;

    Now the subject states the users Email Subject instead of my default.
    Many, many thanks!

    #53194
    Quote:
    – and moved it under the $Message line (but I’m not sure that matters with the above change in place)

    Basically, this line:

    Code:
    $EmailFrom = $Email;

    has to be below the line where the $Email variable is set (see below), otherwise you’ll run into errors.

    Code:
    $Email = Trim(stripslashes($_POST[‘Email’]));
    #54295
    seba
    Member

    Does this form have any spam protection? if not how can it be added, cheers.

    #54296

    I use reCaptcha for spam prevention. Simply sign up for an API key at http://recaptcha.net/ and download the reCaptcha PHP library from http://recaptcha.net/plugins/php/

    To add the reCaptcha to the contact form you simply add the following code (must be a .php file):

    Code:

    Then to verify the captcha you add the following before the email is processed:

    Code:
    require_once(‘recaptchalib.php’);
    $privatekey = “…”; // you got this from the signup page as well
    $resp = recaptcha_check_answer ($privatekey,
    $_SERVER[“REMOTE_ADDR”],
    $_POST[“recaptcha_challenge_field”],
    $_POST[“recaptcha_response_field”]);

    if (!$resp->is_valid) {
    die (“The reCAPTCHA wasn’t entered correctly. Go back and try it again.” .
    “(reCAPTCHA said: ” . $resp->error . “)”);
    }

    #54306

    Yes I must say I hate filling out Captcha’s – we all do. That said I do put them on sites. I think it depends on the amount of traffic you get. Once you start to get above a certain the threshold you seem to get more and more spam. These spammers have even managed to get passed the captcha on these forums – but if you are a small site then a Matcha (math capture?) might be good enough.

    The nice thing about reCaptcha is they use words from scanned in books that their OCR software couldn’t detect. Every time someone feels out a reCaptcha they are (apparently) helping to digitize copies of old books and newspapers. So at least those few seconds went to some good use :-)

    #54336
    ikthius
    Member

    after getting lots of spam, I added a captcha to the sites I am in charge of, and I added the simple math one, as I did not want to deal with a whole load of images that sometimes I can’t read.

    this has greatly decreased the spam to virtually nill, but then I added other parts to my PHP script:

    Code:
    /*
    ******************* checking the script is filled in by humans *******************
    */
    //if email contains nothing, refresh to google and exit the script
    if($email == “”)
    {
    print ““;
    exit;
    }
    //if hidden contains anything, refresh to google and exit the script
    if ($hidden > “”)
    {
    print ““;
    exit;
    }
    //if body contains nothing, refresh to google and exit the script
    if($Body == “”)
    {
    print ““;
    exit;
    }
    //if the HTML captcha answer is not the same as PHP captcha value, refresh to google and exit the script
    if ($captchaHTML != $captchaPHP)
    {
    print ““;
    exit;
    }

    /*
    ******************* checking the body for generated urls if so send to google *******************
    */
    if(preg_match(“/http/i”, “$Body”))
    {
    print ““;
    exit;
    }
    if(preg_match(“/a href/i”, “$Body”))
    {
    print ““;
    exit;
    }
    if(preg_match(“/link=/i”, “$Body”))
    {
    print ““;
    exit;
    }

    you could also use an .htaccess to deny access to a directory that the script is working from, and deny from all the bot servers/ip address, this should eliminate all spam

Viewing 8 posts - 1 through 8 (of 8 total)
  • The forum ‘CSS’ is closed to new topics and replies.