| | |||||
| ||||||||
| CODE This forum is for posting code snippets and example scripts that aren't quite tutorials, but could be useful for others. You may post code snippets and/or completed scripts that you've written and want to share here. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| Account Suspended Join Date: Dec 2008 Location: Boston, Ma
Posts: 650
![]() ![]() ![]() ![]() ![]() ![]() | Clean user posted data Ok this is a common function for cleaning user posted data. I have seen many people's code here, and data cleaning seems to not be getting done. For data being inserted into sql, call this after a mysql connection is opened: PHP Code: PHP Code: To properly call: PHP Code: *As seen in php arcade, I jumped on their butts and told them to start validating data and now they use this too. Oh btw, to those using it.... addslashes() = worthless. Do NOT trust it.
Last edited by CrackFeed.Com; 03-28-2010 at 06:21 AM.
|
| | |
| | #6 (permalink) |
| NamePros Regular Join Date: Nov 2007 Location: UK
Posts: 403
![]() ![]() ![]() | This is another take on my method, actually quite a lot clearer. Thanks for the share, will implement myself.
__________________ 3cc Internet |
| | |
| | #8 (permalink) |
| NamePros Regular Join Date: Nov 2007 Location: UK
Posts: 403
![]() ![]() ![]() | It was something I'd used since starting PHP which essentially strips out anything except what I've specified - because I like having control over what characters I have in my inputs. But that does cause problems when users don't get back what they entered so I've been considering updating the libraries for a while, especially as ereg_replace and it's family are now depreciated in the latest PHP versions
__________________ 3cc Internet |
| | |
| | THREAD STARTER #10 (permalink) |
| Account Suspended Join Date: Dec 2008 Location: Boston, Ma
Posts: 650
![]() ![]() ![]() ![]() ![]() ![]() | Thanks everyone, very kind I am glad to help!????: NamePros.com http://www.namepros.com/showthread.php?t=647375 Yeah I am sad to see ereg go, but oh well |
| | |
| | #11 (permalink) |
| NamePros Regular Join Date: Nov 2007 Location: UK
Posts: 403
![]() ![]() ![]() | I'd be interested to hear your take on this, how would you sanitize a password before entry into a database? On a basic database I then only md5 the passwords after cleaning strings but seeing as users are beginning to use symbols...
__________________ 3cc Internet |
| | |
| | THREAD STARTER #12 (permalink) |
| Account Suspended Join Date: Dec 2008 Location: Boston, Ma
Posts: 650
![]() ![]() ![]() ![]() ![]() ![]() | If you are simply MD5()ing the password then inserting into the database, then that is all the sanitation that you need. if you plan to display the password or email it to the user, then I would run it through htmlentities(). ????: NamePros.com http://www.namepros.com/showthread.php?t=647375 PHP Code:
Last edited by CrackFeed.Com; 04-06-2010 at 11:10 AM.
|
| | |
| | #13 (permalink) |
| NamePros Regular Join Date: Nov 2007 Location: UK
Posts: 403
![]() ![]() ![]() | Cool, that's what I had. Thanks for the reply - have restored my faith in md5
__________________ 3cc Internet |
| | |