| | |||||
| ||||||||
| 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 Closed Join Date: May 2004 Location: /etc/passwd
Posts: 2,178
![]() ![]() ![]() ![]() ![]() ![]() | SQL Injection Prevention Code: PHP Code: Basicly this code is probably good to be put in a config file. Reason for this code is so you dont have to worry about SQL Injection prevention what so ever in your coding, cause its already done in your config file. When you pull records from mysql or something, you will need to do something like this: PHP Code: To learn more about php scecurity look at this PHP Security Magazine: http://www.insecuremagazine.com/INSECURE-Mag-2.pdf This has a GREAT article about PHP security and keeping your programming secure. My reason for not using mysql_real_escape_string(), well a lot of people dont even know this function exists, and addslashes/stripslashes is more common. But yet, they do almost the same exact thing. Just a new name, and this is how most big websites do it, you can even take a look at most of the popular forum software, they use addslashes/stripslashes. What is SQL injection:
Cody
Last edited by axilant; 10-03-2005 at 01:39 PM.
| ||||
| |
| | #2 (permalink) |
| Senior Member Join Date: May 2005 Location: I'm right here
Posts: 3,526
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Thanks a lot. I was coding from scratch, so I think I can use something like this now.
__________________ WP Theme Developer Your One-stop for Premium Magazine/CMS WordPress Themes Deluxe Themes |
| |
| | #6 (permalink) |
| Senior Member Join Date: May 2005 Location: I'm right here
Posts: 3,526
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | mysql_real_escape_string() works very well. And its suggested by the php manual.
__________________ WP Theme Developer Your One-stop for Premium Magazine/CMS WordPress Themes Deluxe Themes |
| |
| | THREAD STARTER #7 (permalink) | ||||
| Account Closed Join Date: May 2004 Location: /etc/passwd
Posts: 2,178
![]() ![]() ![]() ![]() ![]() ![]() |
![]() Alright. Heres my NEW mysql class, i decided to go back and rewrite it using my "escape" function PHP Code: use: PHP Code: Im updating this in 5-10 minutes. Edit: Updated. (I saw an error.)
Last edited by axilant; 07-28-2005 at 03:40 PM.
| ||||
| |
| | #8 (permalink) |
| Senior Member Join Date: May 2005 Location: I'm right here
Posts: 3,526
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Very nice, but its very complicated to me only. ![]() I'm not too familiar with classes, well I think I would stick with the input validation at the first place (first post).
__________________ WP Theme Developer Your One-stop for Premium Magazine/CMS WordPress Themes Deluxe Themes |
| |
| | #10 (permalink) |
| Eating Pie Join Date: Nov 2004 Location: Canada
Posts: 2,272
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | One of the other biggest made ways to injection is $select = "SELECT *..."; Than $select = mysql_query($select); This opens up to a way where the user can just do index.php?select=DELETE FROM clients WHERE user=bob Something as easy as that can destory a business. But yes I reccommand the script above to new programmers. More advanced ones have other ways in which to make sure no sql injections occur. Regards,
__________________ I feel old. |
| |
| | #11 (permalink) | ||||
| Senior Member Join Date: May 2003
Posts: 2,187
![]() ![]() ![]() |
| ||||
| |
| | THREAD STARTER #12 (permalink) | ||||
| Account Closed Join Date: May 2004 Location: /etc/passwd
Posts: 2,178
![]() ![]() ![]() ![]() ![]() ![]() |
????: NamePros.com http://www.namepros.com/showthread.php?t=108827 even if you encrypt them... its still not safe... theres ways to decrypt most things including md5 (takes a while though, visual basic program that will keep running till it finds a match ^^) | ||||
| |
| | #13 (permalink) |
| Senior Member Join Date: May 2005 Location: I'm right here
Posts: 3,526
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | That's weird..I never heard about passing queries through URLs.
__________________ WP Theme Developer Your One-stop for Premium Magazine/CMS WordPress Themes Deluxe Themes |
| |
| | THREAD STARTER #15 (permalink) |
| Account Closed Join Date: May 2004 Location: /etc/passwd
Posts: 2,178
![]() ![]() ![]() ![]() ![]() ![]() | I bring this topic back up because i have made the first post in this thread much better, to explain it a bit better than i have before. Website Security is probably the hardest thing to come by. |
| |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| M6.Net has the SQL plan for developers looking for space and freedom. | priyanka[imported] | Web Hosting Offers | 1 | 07-22-2005 02:22 AM |
| Free cPanel, RvSkins, Fantastico, SQL Hosting! | dc1pop | Web Hosting Offers | 0 | 06-26-2005 08:29 AM |
| $ 6.95 Windows Hosting :: MS SQL, ASP.NET, Cold Fusion, Oracle, Multiple domains | JodoHost | Web Hosting Offers | 0 | 03-27-2005 05:36 AM |
| Connecting to your SQL Database using Enterprise Manager | priyanka[imported] | Web Hosting Discussion | 1 | 12-07-2004 04:21 PM |
| Connecting to your SQL Database using Enterprise Manager | priyanka[imported] | Webmaster Tutorials | 0 | 12-06-2004 09:58 PM |