Text box value, backslash, and PHP variable

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John

    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
  • Geoff Berrow

    #2
    Re: Text box value, backslash, and PHP variable

    I noticed that Message-ID:
    <1ab390bb.03112 61529.1ed9978@p osting.google.c om> from John contained the
    following:
    [color=blue]
    >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?[/color]

    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/

    Comment

    • Xenofon Papadopoulos

      #3
      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_g pc' ) ? 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_gp c is not set by your system
      administrator, you may corrupt your input data.

      Comment

      Working...