![]() |
![]() |
![]() |
|||||
![]() |
![]() |
![]() |
![]() |
![]() |
|||
| Welcome
to Tech Support Forum home to more then 136,000 problems solved. Issues
have included: Spyware, Malware, Virus Issues, Windows, Microsoft,
Linux, Networking, Security, Hardware, and Gaming Getting your
problem solved is as easy as: 1. Registering for a free account 2. Asking your question 3. Receiving an answer Registered members: * See fewer ads. * And much more..
|
| Want to know how to post a question? click here | Having problems with spyware and pop-ups? First Steps |
|
|||||||
| Web Design & Programming Discussion of web design, and server-side & client-side scripting |
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 (permalink) |
|
Design Team Member
|
PHP: Sanitizing Forms
Security is always a big deal and something we don't bring up very often on this forum as this is largely a help forum, not a tutorial site...and it's incumbent on each developer to ensure their code is safe rather than the moderators/helpers here holding their hand through everything. That said, some guidance is always nice too :) There are tons of articles out there, so I'm not going to go crazy with examples - and this isn't designed to be an "end-all" security post, but rather a few nifty articles and a start of discussion for others as well.
One big deal is sanitizing ANYTHING that is passed from a user on your site. I'm not a security expert as I don't deal as much with security things these days since I largely work on an intranet system for my office, but there are fundamental things everyone should do regardless. PHP5 has a great new function called "filter_var" and there are tons of filter flags you can put into it to do a myriad of things. Here is a great article on TutsPlus regarding this function: http://net.tutsplus.com/tutorials/ph...h-php-filters/ If you have the access rights to do so, you should turn off magic_quotes (addslashes/removeslashes manually is *probably* best - extra work, but extra control) as well as register_globals. If you like, you may also want to turn errors off that way "villains" can't see what is wrong with your code if things aren't working properly and don't have clues on how to use that against you. This is probably easier to do if you have a secondary server that you can test on. I don't run things that way currently, so I have errors on (although turned down quite a bit). SQL injection is one of the worst things that can happen to your site. It not only affects your site, but also the integrity of the data in your database. If you use MySQL, you can use the mysqli_real_escape_string function to escape special characters and therefore sanitize the form element: PHP Code:
PHP Code:
Another thing you can do - especially with comment/contact forms, is utilizing captcha. Here's a popular library: http://recaptcha.net/plugins/php/ Some developers flat out do not like captcha, don't want anything to do with it, and regularly encourage others not to bother with it. My opinion is that if it keeps even 40% of bots out, it's worth it - so long as it doesn't destroy the user's experience on the site either. That's about all I have for now. I'm more interested in others contributing more rather than trying to put a ton of stuff up... :P
__________________
Free Resources PC Protection - Comodo Firewall | AVG Anti-Virus | WinPatrol | Ad-Aware | Spybot S&D | SpywareBlaster |Web Design/Programming - KompoZer (Editor) | Paint.NET (Graphic) | GIMP+GIMPShop (Graphic) | FileZilla (FTP Client) | Free Hosting | |
|
|
|
| Important Information |
|
Join the #1 Tech Support Forum Today - It's Totally Free!
TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free. Join TechSupportforum.com Today - Click Here |
![]() |
| Thread Tools | |
|
|