Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,172
    Thanks
    19
    Thanked 65 Times in 64 Posts

    mail contact form

    I hve a problem with my email form, it works every time I test it but I keep getting blanks through from my website. As if someone has tried to email me but not filled the form in (I know, I need to put validation on) I dont know if I'm missing people trying to contact me or if something is going wrong. I know someone from this forum submitted the contact form yesterday but it came through blank and I dont know if it was really blank or not.
    Has anyone ever experienced this?

  • #2
    Regular Coder
    Join Date
    Feb 2005
    Location
    West Midlands, UK
    Posts
    623
    Thanks
    0
    Thanked 0 Times in 0 Posts
    We have a lot of clients with these forms and we used to get blank ones through all the time before I implemented some basic validation. Sometimes people click the button by mistake or maybe they get triggered by bots, sometimes it might even be a malicious user looking for vulnerabilities in a form, who knows, I gave up trying to figure it out a long time ago

    You generally only need to put validation on one field to filter these out, something as simple as:
    PHP Code:
    $_POST['name'] = (isset($_POST['name']) ? trim($_POST['name']) : ''); // we'll do a basic test on the user's name
    if(empty($_POST['name'])) {
        exit(
    'You did not enter your name. Please click back in your browser and try again.');

    I use a similar system for my validation and couple it with sessions to send back the post data and populate the form so the user doesn't have to re-enter their data each time, just the fields that need attention and it's cleared up the problem of ghost forms completely.

  • #3
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,172
    Thanks
    19
    Thanked 65 Times in 64 Posts
    Glad its not just me then. For clients I always put validation on but I didnt bother on this one cos its just for me, one of those things on the ever increasing 'to do' list of my life lol


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •