Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Form Data PHP

  • 22-07-2009 03:29PM
    #1
    Closed Accounts Posts: 2,828 ✭✭✭


    I am just wondering how would you strip form input of slashes, hypens, brackets, html tags, quotations and just have the raw text left over. Is there a PHP function to accomplish this, I am wanting to make the data safe to use in a database.

    Thanks


Comments

  • Registered Users, Registered Users 2 Posts: 3,745 ✭✭✭laugh


    A combination of htmlentities, strip_tags and any other functions or custom code as filters first and then mysql_real_escape_string when inserting.

    I would read the pages on php.net for those for a start, just add the name on the end like this http://ie.php.net/strip_tags


  • Closed Accounts Posts: 7,144 ✭✭✭DonkeyStyle \o/


    I like regular expressions, if you don't absolutely need to store a lot of special characters... like for example form input where you know exactly what to expect.
    Instead of trying to prepare for everything that might be thrown at, just pick out the part of the input you're expecting and dump the rest.

    look up preg_match_all() there are plenty of examples for popular tasks.


Advertisement