Text box value, backslash, and PHP variable

This is a discussion on Text box value, backslash, and PHP variable within the PHP Language forums, part of the PHP Programming Forums category; I have a form with a textbox. On submitting the form I read the textbox value into a php variable. ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 11-26-2003
John
 
Posts: n/a
Default Text box value, backslash, and PHP variable

I have a form with a textbox. On submitting the form I read the
textbox value into a php variable. If the value in the text box
contained a ' or " anywhere in the string, the php variable adds a
backslash ahead of the character. How can I get rid of this unwanted
backslashes?

Thank you
John
Reply With Quote
  #2 (permalink)  
Old 11-26-2003
Geoff Berrow
 
Posts: n/a
Default Re: Text box value, backslash, and PHP variable

I noticed that Message-ID:
<1ab390bb.0311261529.1ed9978@posting.google.com> from John contained the
following:

>I have a form with a textbox. On submitting the form I read the
>textbox value into a php variable. If the value in the text box
>contained a ' or " anywhere in the string, the php variable adds a
>backslash ahead of the character. How can I get rid of this unwanted
>backslashes?


stripslashes()

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Reply With Quote
  #3 (permalink)  
Old 11-27-2003
Xenofon Papadopoulos
 
Posts: n/a
Default Re: Text box value, backslash, and PHP variable

Better use a function like this to read your post variables:

function raw_param( $name ) {
return ini_get( 'magic_quotes_gpc' ) ? stripslashes( $name ) : $name;
}

$x = raw_param( $_POST[ 'varname' ] );

This way your script will work regardless of your php setup. If you use
stripslashes() and magic_quotes_gpc is not set by your system
administrator, you may corrupt your input data.

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 08:51 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0