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
    New Coder
    Join Date
    May 2009
    Location
    Pennsylvania, United States
    Posts
    54
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Question Flat file database input cleansing...

    I'm working on a small project. It uses flat files, not MySQL. I know that anything being recorded to the database should be checked and cleaned.

    I'm just wondering, should I use the following code in my function:

    PHP Code:
    if(get_magic_quotes_gpc()) $str stripslashes($str); 
    Making my cleansing function:

    PHP Code:
    function cleaninput($str) {
    $str trim(strip_tags($str));
    $str htmlentities($str);
    if(
    get_magic_quotes_gpc()) $str stripslashes($str);
    return 
    $str;

    Any suggestions?

  • #2
    Senior Coder kbluhm's Avatar
    Join Date
    Apr 2007
    Location
    Philadelphia, PA, USA
    Posts
    1,509
    Thanks
    3
    Thanked 258 Times in 254 Posts
    How are you writing to your files? Is it a line-by-line delimited text file, a PHP file containing arrays, etc?

  • #3
    New Coder
    Join Date
    May 2009
    Location
    Pennsylvania, United States
    Posts
    54
    Thanks
    16
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by kbluhm View Post
    How are you writing to your files? Is it a line-by-line delimited text file, a PHP file containing arrays, etc?
    Here's how my file will look:

    1|John|Photoshop,Illustrator
    2|Katie|Coding,PHP,CSS,HTML
    3|Adam|Illustration
    4|Carly|Developer


  •  

    Tags for this Thread

    Posting Permissions

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