Thread: Input format

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    3
    Rep Power
    0

    Input format


    Hi,
    I have a simple web form for my users to apply for a registration key. It would appear every spammer in the world has found my form and I am getting flooded with spam emails making it tough to sort through them to find valid user requests.
    I have an input value that would be easy to check but have no idea how to do it.
    My users must enter a registration number in the format:
    xxxx-xxxx-xx eg. 12SD-1GHJ-13

    The spammer typically are using Yes or No for this value along with many other inputs.
    Is there any way to check this format and if it is incorrect just give the normal email sent notice But not send me the email... giving the spammer no indication he did anything other than send the email.

    Thanks
    --Don
  2. #2
  3. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,141
    Rep Power
    9398
    Regular expressions are quick for it. Letters and numbers?
    PHP Code:
    if (preg_match('/^[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9}{2}$/i'$input)) {
        
    // valid
    } else {
        
    // invalid

    What about people who mistype the registration number?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    3
    Rep Power
    0
    Originally Posted by requinix
    Regular expressions are quick for it. Letters and numbers?
    PHP Code:
    if (preg_match('/^[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9}{2}$/i'$input)) {
        
    // valid
    } else {
        
    // invalid

    What about people who mistype the registration number?
    Hm-mm I hadn't thought about that being so po'd about all the spam (now up to about 60 an hour)... The funny thing is the proper format is listed in the form header they or it if a bot just doesn't use it. The number is built on each machine during install so I have no list of possibles or anything.
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    3
    Rep Power
    0
    I am not sure where I would add the code. I am using just a simple php form from when I was on Godaddy... I am not a PHP or Website programmer, I know just enough to get my product for download online.

    The value to be checked will be the 3rd one


    <?php
    $request_method = $_SERVER["REQUEST_METHOD"];
    if($request_method == "GET"){
    $query_vars = $_GET;
    } elseif ($request_method == "POST"){
    $query_vars = $_POST;
    }
    reset($query_vars);
    $t = date("U");


    $file = $_SERVER['DOCUMENT_ROOT'] . "/../data/gdform_" . $t;
    $fp = fopen($file,"w");
    while (list ($key, $val) = each ($query_vars)) {
    fputs($fp,"<GDFORM_VARIABLE NAME=$key START>\n");

    'loops all input values from form
    'form value name=RegistrationNumber
    'So would trap be
    if $key="RegistrationNumber"

    'if (preg_match('/^[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9}{2}$/i', $val)) {
    // valid
    } else {
    // invalid
    }


    fputs($fp,"$val\n");

    'New code suggested:
    'if (preg_match('/^[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9}{2}$/i', $input)) {
    // valid
    } else {
    // invalid
    }





    fputs($fp,"<GDFORM_VARIABLE NAME=$key END>\n");
    if ($key == "redirect") { $landing_page = $val;}
    }
    fclose($fp);

    if ($landing_page != ""){
    header("Location: http://".$_SERVER["HTTP_HOST"]."/$landing_page");
    } else {
    header("Location: http://".$_SERVER["HTTP_HOST"]."/");
    }


    ?>

IMN logo majestic logo threadwatch logo seochat tools logo