943,614 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 1565
  • PHP RSS
You are currently viewing page 3 of this multi-page discussion thread; Jump to the first page
Aug 22nd, 2009
0

Re: How to secure my web

It's very possible. mysql_real_escape_string() only escapes special characters such as " and ' that can make your queries vulnerable to a MySQL injection. Inserting script into a query is not MySQL injection as it doesn't affect the database. The danger is when other people view a page that uses this content. The script can get cookies from the user such as password and username and send them to script on their site that saves them. To protect again this all you have to do is escape < and > with their HTML equivalents ( &lt; and &gt; ):
PHP Syntax (Toggle Plain Text)
  1. $comment=mysql_real_escape_string(str_replace("<", "&lt;", str_replace(">", "&gt;", $_POST['comment'])));
Last edited by FlashCreations; Aug 22nd, 2009 at 8:22 pm.
Reputation Points: 47
Solved Threads: 47
Posting Whiz
FlashCreations is offline Offline
393 posts
since Sep 2008
Aug 22nd, 2009
0

Re: How to secure my web

Thats not sql injection. It's called xss.

You need to run the data through the php function htmlentities().
Reputation Points: 235
Solved Threads: 193
Nearly a Posting Virtuoso
kkeith29 is offline Offline
1,315 posts
since Jun 2007
Aug 22nd, 2009
0

Re: How to secure my web

thankx for your suggestions,i will work on it.
Reputation Points: 17
Solved Threads: 8
Posting Whiz in Training
mrcniceguy is offline Offline
278 posts
since Mar 2008
Aug 23rd, 2009
0

Re: How to secure my web

i tried
php Syntax (Toggle Plain Text)
  1. $comment=mysql_real_escape_string(str_replace("<", "&lt;", str_replace(">", "&gt;", $_POST['comment'])));
and htmlentities() they are doing the same thing.
Is the anything more i should take care of ???
Reputation Points: 17
Solved Threads: 8
Posting Whiz in Training
mrcniceguy is offline Offline
278 posts
since Mar 2008
Aug 23rd, 2009
0

Re: How to secure my web

You probably should use htmlentities as it is a function that is packaged with PHP and therefore does a lot more then replace the < and >. In fact, htmlentities escapes all characters that have HTML "entity equivalents" (&gt; or &lt; for example). Since htmlentities does a lot more then my two str_replaces, I would use htmlentities. Off the top of my head, I can't think of anything else if you've tried something similar to my unique key system (and removed that cookie that stores the user's password!).
Last edited by FlashCreations; Aug 23rd, 2009 at 1:10 pm.
Reputation Points: 47
Solved Threads: 47
Posting Whiz
FlashCreations is offline Offline
393 posts
since Sep 2008
Aug 23rd, 2009
0

Re: How to secure my web

Is there a way someone could use GET OR REQUEST ,TO harm my site?
bcoz up to this moment,i were just dealing with the inputs POST.
Reputation Points: 17
Solved Threads: 8
Posting Whiz in Training
mrcniceguy is offline Offline
278 posts
since Mar 2008
Aug 23rd, 2009
0

Re: How to secure my web

As long as you don't use the $_GET[] variable without sanitizing or replacing html entities you should be safe. If you don't use it, there's no way for it to be hacked!
Reputation Points: 47
Solved Threads: 47
Posting Whiz
FlashCreations is offline Offline
393 posts
since Sep 2008
Aug 25th, 2009
0

Re: How to secure my web

AS i were still working with the security issue,through Google search i found one PHP CLASS which the input filters(GET,POST AND REQUEST).
HERE IS THE LINK
www.phpclasses.org/browse/package/2189.html
Reputation Points: 17
Solved Threads: 8
Posting Whiz in Training
mrcniceguy is offline Offline
278 posts
since Mar 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: PhoneBook Script [Project]
Next Thread in PHP Forum Timeline: Images made from Blob are Cut Off





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC