Results 1 to 4 of 4

Thread: need to restricting forms submits based on data

  1. #1
    Join Date
    Jan 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default need to restricting forms submits based on data

    I have a form located here https://www.lgw.com/dev/sampleformcard.htm

    and I'd like to stop people from submitting the form if there credit card starts with several different combination of 4 numbers.

    The list is very long (almost 300 different combo) and I was looking for suggestions on how I could accomplish this.

    My first thought was it break up the one field into 4 fields, (like the four groups of numbers on your credit card) and just run the filter on the first field.

    what programming language would I use? maybe PHP and run it against a CSV file?

    Any direction would be helpful.


    Regards,
    Chris

  2. #2
    Join Date
    Jan 2007
    Posts
    629
    Thanks
    10
    Thanked 28 Times in 28 Posts

    Default

    PHP would do great, and you would not have to break it up into four feilds-- just use the preg_split functions to grab the first four numbers. You could also store the numbers in a MySQL database and retrive them that way, as opposed to the CSV, but whatever way you like.
    --Jas
    function GreatMinds(){ return "Think Like Jas"; }
    I'm gone for a while, but in the meantime: Try using my FTP script | Fight Bot Form Submissions

  3. #3
    Join Date
    Jan 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I have no experience in mySQL, but PHP might be the way to go, any chance you could show a sample, and/or point me to a sample?


    thanks
    Last edited by ChrisVersion2; 01-16-2008 at 08:16 PM.

  4. #4
    Join Date
    Jan 2007
    Posts
    629
    Thanks
    10
    Thanked 28 Times in 28 Posts

    Default

    I threw this together really quick, but hopefully it works.
    PHP Code:
    <?php

    //check to see if the form has been set
    if(isset($_POST['submit'])){
        
    #CONNECT TO MYSQL HERE
        //get first 4 numbers
        
    $credit preg_split("/[\D{5}]/",$_POST['number']);
        
    //look in mysql for the numbers
        
    $rows MySQL_query("SELECT * FROM table WHERE number = \"".$credit[0]."\"");
        
    //see if there was at least one match
        
    if(MySQL_num_rows($rows) <= 1){\
            die(
    'FOUND A MATCH FOR THE CREDIT CARD NUMBER');
        }else{
            
    //process the info
        
    }
        
    }else{
        echo 
    "<form action='".$_SERVER['PHP_SELF']."' method='POST'>
        <input type='text' name='number'>
        <input type='submit' name='submit' value='submit'>    
    </form>"
    ;
    }

    ?>
    --Jas
    function GreatMinds(){ return "Think Like Jas"; }
    I'm gone for a while, but in the meantime: Try using my FTP script | Fight Bot Form Submissions

Bookmarks

Posting Permissions

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