Skip to content

5 Comments

leave a comment
  1. andy / Apr 5 2010

    putting this info into hidden fields is pointless and potentially buggy. Your form submits to a script, so get that info in the submission script away from th users form markup or scam robots interaction. The only exception would be th referrer info, which could stay in th hidden field, but again, its potentially buggy.
    Dont forget the sanity checks serverside too.

  2. Morris / Apr 5 2010

    How do you suggest I do that, working with the above code? Thanks for your advice.

  3. andy / Apr 7 2010

    The submission script would be the file the form gets posted to. I see in your “action” you have “http://site.com/”, lets start from there.

    say your “action” is “http://site.com/submit.php”, the submission script would be submit.php

    In submit.php, you would have all your validation:

    check “name” is not empty with:
    if(strlen($name) == ‘0′){
    //do something on error
    }
    check “email” is valid with check_email_address() function found here: http://www.linuxjournal.com/article/9585

    remember to do something on error again

    After validation, you’d then do your IP check before inserting into the database and redirecting to the “Thank you” page.

    The only problem would be that $_SERVER['HTTP_REFERRER'] in submit.php would be the page where your form is, so you’d still need that in your hidden fields. Or use cookies, which you’ve already ruled out.

    The reason Im saying do the IP stuff in your submit page is:
    A) hidden fields can be overwritten by robots
    B) you’re depending on a 3rd party script for information, if there’s a hang at the 3rd party site, the form would take ages to load in and you’ll lose your user.

    Your theory is sound enough Morris, it’s just the location of certain parts that could be improved to give a better user experience equaling more leads + more money for you.

  4. Morris / Apr 7 2010

    Thanks a lot for your suggestions – I appreciate it.

    I’m actually submitting the form to a third party (Campaign Monitor), so I’m not sure how possible it is to pass it through another submit.php type page and add the IP stuff there.

    I also understand the downside of using a third party to find the location of the IP, though uploading and sourcing the country code MySQL stuff was a bit beyond me, this time :)

    Thanks again.

Trackbacks and Pingbacks

  1. Capture user’s IP, location and referring URL in subscriber form
Leave a Comment