Jump to content


Photo

Backslashes


  • Please log in to reply
4 replies to this topic

#1 rshadarack

rshadarack
  • Members
  • PipPip
  • Member
  • 29 posts

Posted 10 September 2006 - 01:41 AM

Is there a way for me to take backslashes from a form input, and replace it with \ (the html '\' code)?  By the time I retrieve data using post, the backslashes are gone already.

#2 jefkin

jefkin
  • Members
  • PipPipPip
  • Advanced Member
  • 55 posts

Posted 10 September 2006 - 03:10 AM

Hi, rshadarack,

Sounds like a client side issue, so you could alway write some javascript to do it ... but ...

the problem with replacing them in the client's html side is they're turned back into backslashes when it transfers to the server.

Your real problem, as you can guess, is that once in the server side they can be stripped out depending on your PHP ini settings.  I'm not much of a sys-admin type, but there are some others here that can probably point you in the right direction.

Jeff

#3 tleisher

tleisher
  • Members
  • PipPipPip
  • Advanced Member
  • 88 posts

Posted 10 September 2006 - 04:17 AM

Couldn't he just use str_replace()?

http://us3.php.net/m...str-replace.php

#4 jefkin

jefkin
  • Members
  • PipPipPip
  • Advanced Member
  • 55 posts

Posted 11 September 2006 - 01:30 AM

You may be right tleisher,

but without his code, I just guessed that he's having a problem retrieving the '\' on the php side.  before he could get to it with a str_replace().

Maybe I missunderstood. 

If so, appologies rshadarack.

Otherwise, I'm thinking the problem is he's got magic_quotes or some such set to muddle with his form input strings.

Like I said, could be wrong...

Jeff

#5 Nhoj

Nhoj
  • Members
  • PipPipPip
  • Advanced Member
  • 223 posts
  • LocationClearwater, FL

Posted 11 September 2006 - 01:57 AM

I'd recomend just using

html_entities($_POST['FORM'], ENT_QUOTES);
That way all the HTML entered would become "safe"...'er'
Avid PHP Developer, need some work done? Send a PM ;)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users