[PHP] Anti-SQL Injection

Results 1 to 8 of 8
  1. #1
    http://kalserverace.com Ace-SG1- is offline
    MemberRank
    Sep 2006 Join Date
    HawaiiLocation
    1,711Posts

    [PHP] Anti-SQL Injection

    PHP Code:
    <?php

    // Anti-SQL Injection 
    function check_inject() 
      { 
        
    $badchars = array(";""'"" \ ""DROP""SELECT""drop""select"); 
       
        foreach(
    $_POST as $value
        { 
        
    $value clean_variable($value);

        if(
    in_array($value$badchars)) 
          { 
            die(
    "SQL Injection Detected - Make sure only to use letters and numbers!\n<br />\nIP: ".$_SERVER['REMOTE_ADDR']);
          } 
          else 
          { 
            
    $check preg_split("//"$value, -1PREG_SPLIT_OFFSET_CAPTURE);
            foreach(
    $check as $char
            { 
              if(
    in_array($char$badchars)) 
              { 
                die(
    "SQL Injection Detected - Make sure only to use letters and numbers!\n<br />\nIP: ".$_SERVER['REMOTE_ADDR']); 
              } 
            } 
          } 
        } 
      } 
    function 
    clean_variable($var
        { 
        
    $newvar preg_replace('/[^a-zA-Z0-9\_\-]/'''$var); 
        return 
    $newvar
        }

    ?>
    Have fun kids.


  2. #2
    aka Reb3lzrr Boarderkoen is offline
    MemberRank
    Aug 2006 Join Date
    boskoopLocation
    669Posts

    Re: [PHP] Anti-SQL Injection

    If this works it would be nice :D

  3. #3
    Laravel Core Programmer Jangan is offline
    DeveloperRank
    Jul 2007 Join Date
    Dubai, UAELocation
    2,113Posts

    Re: [PHP] Anti-SQL Injection

    good job, hope it works, i will tell luca to test it out =D

  4. #4
    Account Upgraded | Title Enabled! NarutaruTR is offline
    MemberRank
    Jun 2007 Join Date
    803Posts

    Re: [PHP] Anti-SQL Injection

    Is this now Working?

  5. #5
    Get Rich.. or something.. HandsOfGod is offline
    MemberRank
    Dec 2006 Join Date
    IsraelLocation
    763Posts

    Re: [PHP] Anti-SQL Injection

    Should work :P

    for now

  6. #6
    http://kalserverace.com Ace-SG1- is offline
    MemberRank
    Sep 2006 Join Date
    HawaiiLocation
    1,711Posts

    Re: [PHP] Anti-SQL Injection

    it beter work... lol.

  7. #7
    Alpha Member Shortor is offline
    MemberRank
    Jun 2007 Join Date
    1,627Posts

    Re: [PHP] Anti-SQL Injection

    you call us kids?

    Quote Originally Posted by AceSG on Coders Paradise
    hmm any one? no one can tell me if this well block SQL injections??!!??!!
    you can't do shit yourself :) you pasted some public reg script and the others made it secure for you..

    source: http://forum.ragezone.com/f144/php-s...0/#post2493050

  8. #8
    Enthusiast xghDixi is offline
    MemberRank
    Sep 2007 Join Date
    d1 r5Location
    37Posts

    Re: [PHP] Anti-SQL Injection

    thanks for that Ace - SG1

    i hope it works xD



Advertisement