Grow your CSS skills. Land your dream job.

PHP Contact Form SPAM!

  • Bob
    # January 16, 2011 at 7:51 am

    isEmail() is not a function for PHP, as far as I know, so either you have to create the function first or you can try the function is_email() thats built into WordPress.

    gno
    # January 16, 2011 at 5:22 pm

    Bob is right. isEmail is a custom function, so you have most likely fucked something up when you attempted to implement my solution. It’s probably an include or require call you have removed.

    # January 16, 2011 at 6:51 pm

    Sorry guys, I’m so clueless on php. I’m confused because I haven’t edited my form at all except for what Gno suggested I do. So the isEmail() has always been part of the form and has been working fine. I’m not sure what I can do now. UGH! I thought I was close! Unfortunately I am using this form on another site, and now that email address is getting bombarded from a spambot as well. So I have to find something.

    # January 16, 2011 at 6:55 pm

    So I took out what you suggested Gno, and retested and the form works perfect. So your suggestion is clashing with the isEmail() part for some reason.

    Rob
    # January 17, 2011 at 4:14 am

    Ok here is a quick explanation of what just happened.

    PHP as you might have guessed has lot’s of built in functions for example is_array() gives you a true and false answer if something is an array or not. But you can write your own functions for PHP – as that is how you create applications etc etc…

    So what someone has done with that script is create a function called isEmail() – which is not in PHP by default – and it is probably a regular expression match against if the email address given by the user is actually an email address or just a load of rubbish. If it is an email address you will get a true response, if not a false one. This will then give the answer to this part of your code.


    elseif(!isEmail($email)) { $error .= '
  • You have entered an invalid e-mail address.
  • '; }

    it reads:

    if *Email is not actually an email* then the variable “error” equals *line of HTML error message*

    So what has happened is somewhere along the line your isEmail() function has been removed or it’s name has changed. Normally things like this are “included” – so you would have another file with more PHP in it that you include into the main body of PHP – it saves space and lets your functions be kept nice and tidy :D

    I would really recommend having a run through some basic PHP tutorials:

    http://blog.themeforest.net/screencasts/diving-into-php-video-series/

    This is good – if you go through them in about 2hrs you will have a massive jump on your understanding :)

    gno
    # January 17, 2011 at 7:51 am

    @Preeminent, I can ensure you that there is no way, that my “solution” to your problem is clashing with your script.

    What is does is just to check if the field that we hide with css is empty. The problem is most likely your implementation of it.

    The code which is sending your email should just be wrapped by if ($_POST == '') { and }

    However, if you don’t know how the script works, I think it would be a good idea to look at some php tutorial as Rob suggests. This is very basic PHP (just checking if a given variable has a value or not)

    # January 17, 2011 at 8:26 pm

    Gno, I’m certainly not saying that anything about your spam check is wrong. Hell, I wouldn’t know anyway! But for some reason, with the addition of the spam check, an error occurs with that isEmail() line. And I put the check exactly where you told me to. It’s just odd. But Rob, thanks for your time as well. I’ve got to try and find time to go over those videos, so I can get this to work. Because I really like your idea Gno, I want to try this out. Thanks again guys.

    gno
    # January 18, 2011 at 4:17 am

    @Preeminent. You can try to email me the code if you want to, and I’ll look over it to see if I can spot the flaw :-) My email address is in my profile on this forum.

    # January 21, 2011 at 11:18 pm

    Looks as if Gno’s process works quite well! Still having issues with my personal site’s contact form. Some spam coming from the same few IP’s and servers, but I hope to get to the bottom of that issue soon. This form was being used on two different sites, and it looks like the spam has stopped completely from the other site! Thanks for your help Gno! Does anyone have any good tips on tracking down the origins of emails, by using the info in the headers? I’ve been doing some looking around on this issue. I’ve looked up the IPs and have emailed the companies who own the servers. What else can I do? Every single one of the emails getting through, look to be coming from the same person, just from a few different IPs.

    # June 2, 2013 at 11:49 am

    @gno

    An old post but, Thanks for this, I’m good with html css & jquery but php isn’t my strong suit so appreciate the simple solution.

    gno
    # June 3, 2013 at 6:51 am

    @AlterEagle thanks. :)

Viewing 11 posts - 16 through 26 (of 26 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".