Validate user input





-17
Date Submitted Mon. Oct. 9th, 2006 7:07 AM
Revision 1 of 1
Helper serpentskiss
Tags PHP
Comments 3 comments
A little function that does some basic checking for data input by a user. Should get rid of code injection ;-)

function safeInput($data){
        $cleanData = strip_tags($data);
        $cleanData = ereg_replace("<[^>]*>","",$cleanData);
        $cleanData = preg_replace('/<(.|\s)*?>/', '', $cleanData);
        if ($cleanData == "" || $cleanData == NULL){
                return FALSE;
        } else {
                return $cleanData;
        }
}
 

Jon Thompson

Comments

Comments Don't chew cabbage twice
Mon. Oct. 9th, 2006 7:28 AM    Scripter ctiggerf
Comments SQL Injection
Mon. Oct. 9th, 2006 7:32 AM    Helper BrandonReese
Comments false sense of security
Mon. Oct. 9th, 2006 7:36 AM    Beginner rdivilbiss

Voting