- This topic is empty.
-
AuthorPosts
-
January 16, 2009 at 3:26 pm #23976
JennW
MemberHi. 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!
JennWJanuary 16, 2009 at 3:44 pm #53182falkencreative
MemberI 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;
January 16, 2009 at 5:59 pm #53192JennW
MemberThat 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!January 16, 2009 at 6:06 pm #53194falkencreative
MemberQuote:– 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’]));February 25, 2009 at 6:18 am #54295seba
MemberDoes this form have any spam protection? if not how can it be added, cheers.
February 25, 2009 at 10:19 am #54296davesgonebananas
MemberI 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 . “)”);
}February 25, 2009 at 12:00 pm #54306davesgonebananas
MemberYes 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 :-)
February 26, 2009 at 2:42 am #54336ikthius
Memberafter 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
-
AuthorPosts
- The forum ‘CSS’ is closed to new topics and replies.