Hi I'm getting blank email messages from a contact form I set up on a site. Completely blank. I'm using PHP to run it. Here's an example of what I get:
From: [email] Sent: Thursday, January 15, 2009 8:00 AM To: [email] Subject: Contact Form Submission
Name: Location: Email: Message:
It never happened before, but now I'm getting 2-3 of these a day. Can anyone help? Do I need to ask one of those "what's 2+2" questions?
Sounds like you simply need to add an "Are you human" type of question. You need to make sure that that field gets filled out correctly for the form to be processed. You can always use CAPTCHA, but I hate it so much I'd find something different.
Yep just sounds like you aren't using any validation at all. In a nutshell, you could add an extra input to the form area asking question like 2+2=?. Then in the PHP that "GET"'s the variables like name, email, etc, also GET the value for that input. Wrap the "mail" function in
if ($answer == 4) { // mail function } else { // redirect back to the form page and tell them there was an error }
I'd suggest some client side validation, but it sounds like a bot is probably trying to submit the form, not a human, so that wouldn't help much anyway.
Hi I'm getting blank email messages from a contact form I set up on a site. Completely blank. I'm using PHP to run it. Here's an example of what I get:
From: [email] Sent: Thursday, January 15, 2009 8:00 AM To: [email] Subject: Contact Form Submission
Name: Location: Email: Message:
It never happened before, but now I'm getting 2-3 of these a day. Can anyone help? Do I need to ask one of those "what's 2+2" questions?
How would I do that?
Any help is much appreciated.
grey, if your using the contact form I helped you with add this after the body population part:
this will check for an email address was in the form, and if it was not in the form and a robot activated the script, then send it to google and not send you an email. you could even add in: other if statements:
// redirect to success page // CHANGE THE URL BELOW TO YOUR \"THANK YOU\" PAGE if ($success){ print \"<meta http-equiv=\\"refresh\\" content=\\"0;URL=contactthanks.html\\">\"; } else{ print \"<meta http-equiv=\\"refresh\\" content=\\"0;URL=contactthanks.html\\">\"; } ?>
I'm so sorry if I'm really missing something here, but I don't know how to fix this my self.
How do I validate? Any help is much appreciated!
Chris, I tried using your example on your screencast. Did I miss something?
grey:
what is your html form? post the code here.
I will re-do the php file for you after work:
but your success part has not got an actual handler/sender.
you are sending it to someone, it has a subject, and a body, but a hidden email, what is handling it? That used to be my problem.
Edit:
I have played around with the code, and I changed a couple of things, although I don't know about your set up, but I tried to add in comments where possible. I changed the main contact form to pick up your form, but make sure you put the php file in the correct place, for the html form to action it. I took away the stripslash stuff, as I never got my system to work with that, I use request. also if your using a windows server, you may have to set your ini_set with your main email server/account also I made your redirects one to the thanks another (else) to the error.html (I don't know your error page) there is a redirect to google if the body is empty.
try and test with another email, not from and to your email address, I find this confusing for guessing things
<?php //use the ini_set if using a windows server. you will have to find your email account server ini_set(\"sendmail_from\", \"lady.jan@sbcglobal.net\");
// get posted data into local variables $EmailTo = \"lady.jan@sbcglobal.net\"; // the address you want the form to be sent to $Subject = \"Contact Form Submission\"; // the subject of the form $Name = $_REQUEST['Name']; // The Name field of the form $Location = $_REQUEST['Location']; // the Location field of the form $Email = $_REQUEST['Email']; // the email of the person filling in the form $Message = $_REQUEST['Message']; // the message of the form
//redirect to google if nothing in body of email if($Body == \"\") { print \"<meta http-equiv=\\"refresh\\" content=\\"0;URL=http://www.google.com\\">\"; exit; } //redirect to google if nothing in from email if($Email == \"\") { print \"<meta http-equiv=\\"refresh\\" content=\\"0;URL=http://www.google.com\\">\"; exit; }
// redirect to success page // CHANGE THE URL BELOW TO YOUR \"THANK YOU\" PAGE if ($success){ //add a personal touch by adding another mail function to send a thanks for filling in form email //if you want to use this feature take away the comments /* & */ /* mail($email, $Subject, \"$name\n\nThank you for contacting faulkner ventures.\nWe will contact you as soon as possible regarding your query.\", \"From: <$EmailTo>\", \"lady.jan@sbcglobal.net\"); */ print \"<meta http-equiv=\\"refresh\\" content=\\"0;URL=contactthanks.html\\">\"; } // redirect to error page // CHANGE THE URL BELOW TO YOUR \"Error\" PAGE else{ print \"<meta http-equiv=\\"refresh\\" content=\\"0;URL=error.html\\">\"; } ?>
Dude! You are the best!! I'm starting to understand the way this works. I'm not PHP literate yet, but your help has been an awesome resource!
I did encounter something odd with the code you provided though and I've been trying to fix it.
Seems like the new mail function is sending the thank you email to the "MAILTO" and not from the person who made contact on the web page. Any idea what I'm missing here.
Again, I really appreciate all your help. I also just got myself a lynda.com premium subscription so I'll be on my way to learning PHP. :D
Dude! You are the best!! I'm starting to understand the way this works. I'm not PHP literate yet, but your help has been an awesome resource!
I did encounter something odd with the code you provided though and I've been trying to fix it.
Seems like the new mail function is sending the thank you email to the "MAILTO" and not from the person who made contact on the web page. Any idea what I'm missing here.
Again, I really appreciate all your help. I also just got myself a lynda.com premium subscription so I'll be on my way to learning PHP. :D
I am not literate with php yet, but your original had your email as the email to, and your email as the email from,
make the email from the email of the person sending the form, by providing them with an email field in your form.
I think I mistyped something originally but I sorted it a few hours later.
the code above should work, however, remember if it is a windows server, you need to supply the email root sort of.....
this is your mail function: $success = mail($EmailTo, $Subject, $Body, "From: <$Email>", "lady.jan@sbcglobal.net");
this is mine: $success = mail($EmailTo, $Subject, $Body, "From: <$Email>", "-froot@honeycomb-web.co.uk");
notice mine has -froot, I use my root email account, to send/handle the email, I believe the script will work fine without it, I believe this is for my hosting, as they suggested it. do you have a main account for @sbcglobal.net ?
ik
p.s. is it working? test with someone else filling in the form
To fix the thank you email, change $email to $Email, change whatever the variable is in the mail function to the variable declared near the top of the script for the person who fills in the form. this way it always uses the email that was put in the email field in the form.
Thanks dude! You're the best. Your post really helped out and it seems like the spam has stopped.
Yes, I have @sbcglobal.net on there because I built the site for my mother in law and she wanted to use her regular e-mail and not a @faulknerventures.com one...
Thanks dude! You're the best. Your post really helped out and it seems like the spam has stopped.
Yes, I have @sbcglobal.net on there because I built the site for my mother in law and she wanted to use her regular e-mail and not a @faulknerventures.com one...
I tested it out and seems to be working fine.
Again, thank you soooo much!
-Grey
glad it works,
the spam will not be topped, as someone can still fill in the form with rubbish, but it will stop it from sending an email, without an email address & without a body.
I would however suggest to her that for a professional look, to keep with teh @faulkenventures, it adds more trust I think, but only a suggestion.
Yea, I asked and she has it all set up with her personal account. She's a local artist who just wants something up and running. Guess it doesn't bother her much. What ever the client wants, right? ;)
I'm really happy with the contact form and am happy you helped me with the PHP!
I'm off to lynda.com to keep learning more and more about web design/development.
Again, thank you very much for your help! You're the best!!
It never happened before, but now I'm getting 2-3 of these a day. Can anyone help? Do I need to ask one of those "what's 2+2" questions?
How would I do that?
Any help is much appreciated.
if ($answer == 4) {// mail function
} else {
// redirect back to the form page and tell them there was an error
}
I'd suggest some client side validation, but it sounds like a bot is probably trying to submit the form, not a human, so that wouldn't help much anyway.
grey, if your using the contact form I helped you with add this after the body population part:
this will check for an email address was in the form, and if it was not in the form and a robot activated the script, then send it to google and not send you an email.
you could even add in: other if statements:
also you could add a bit of javascript to your form to make sure a human is populating it with desired details, let me know if you want that.
ik
Here's the site I'm working on. http://www.faulknerventures.com/contact
Here is the PHP:
I'm so sorry if I'm really missing something here, but I don't know how to fix this my self.
How do I validate? Any help is much appreciated!
Chris, I tried using your example on your screencast. Did I miss something?
grey:
what is your html form? post the code here.
I will re-do the php file for you after work:
but your success part has not got an actual handler/sender.
you are sending it to someone, it has a subject, and a body, but a hidden email, what is handling it?
That used to be my problem.
Edit:
I have played around with the code, and I changed a couple of things, although I don't know about your set up, but I tried to add in comments where possible.
I changed the main contact form to pick up your form, but make sure you put the php file in the correct place, for the html form to action it.
I took away the stripslash stuff, as I never got my system to work with that, I use request.
also if your using a windows server, you may have to set your ini_set with your main email server/account
also I made your redirects one to the thanks another (else) to the error.html (I don't know your error page)
there is a redirect to google if the body is empty.
try and test with another email, not from and to your email address, I find this confusing for guessing things
I did encounter something odd with the code you provided though and I've been trying to fix it.
Seems like the new mail function is sending the thank you email to the "MAILTO" and not from the person who made contact on the web page. Any idea what I'm missing here.
Again, I really appreciate all your help. I also just got myself a lynda.com premium subscription so I'll be on my way to learning PHP. :D
I am not literate with php yet, but your original had your email as the email to, and your email as the email from,
make the email from the email of the person sending the form, by providing them with an email field in your form.
I think I mistyped something originally but I sorted it a few hours later.
the code above should work, however, remember if it is a windows server, you need to supply the email root sort of.....
this is your mail function:
$success = mail($EmailTo, $Subject, $Body, "From: <$Email>", "lady.jan@sbcglobal.net");
this is mine:
$success = mail($EmailTo, $Subject, $Body, "From: <$Email>", "-froot@honeycomb-web.co.uk");
notice mine has -froot, I use my root email account, to send/handle the email, I believe the script will work fine without it, I believe this is for my hosting, as they suggested it.
do you have a main account for @sbcglobal.net ?
ik
p.s. is it working?
test with someone else filling in the form
To fix the thank you email, change $email to $Email, change whatever the variable is in the mail function to the variable declared near the top of the script for the person who fills in the form.
this way it always uses the email that was put in the email field in the form.
Thanks dude! You're the best. Your post really helped out and it seems like the spam has stopped.
Yes, I have @sbcglobal.net on there because I built the site for my mother in law and she wanted to use her regular e-mail and not a @faulknerventures.com one...
I tested it out and seems to be working fine.
Again, thank you soooo much!
-Grey
glad it works,
the spam will not be topped, as someone can still fill in the form with rubbish, but it will stop it from sending an email, without an email address & without a body.
I would however suggest to her that for a professional look, to keep with teh @faulkenventures, it adds more trust I think, but only a suggestion.
now you can use that script for other site now.
I'm really happy with the contact form and am happy you helped me with the PHP!
I'm off to lynda.com to keep learning more and more about web design/development.
Again, thank you very much for your help! You're the best!!