Input, POST and double quotes

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

    Input, POST and double quotes

    I am having problems with double quotes inside a post variable. The
    code below illustrates this. If the user enters non-quoted text then
    the code works OK. If "Hello" is entered then I get $some_text equal
    to \"Hello\". What I want is the actual text that the user entered
    and not the processed version.

    I am new to php so please be gentle with me.

    Thanks in advance,
    Mark

    <?php
    if (isset($_POST['some_text']))
    $some_text = $_POST['some_text'];
    else
    $some_text = "";
    ?>
    <html><body>
    <form method="POST" action="test.ph p">
    <p>
    <?php echo("Old text: " . htmlentities($s ome_text). "<br>"); ?>
    Enter text: <input name="some_text " size="20"><br>
    <input type="submit" value="Submit" name="Submit">
    </p>
    </form>
    </body></html>
    --
    |\ _,,,---,,_ A picture used to be worth a
    ZZZzzz /,`.-'`' -. ;-;;, thousand words - then along
    |,4- ) )-,_. ,\ ( `'-' came television!
    '---''(_/--' `-'\_)

    Mark Stevens (mark at thepcsite fullstop co fullstop uk)
  • steven mestdagh

    #2
    Re: Input, POST and double quotes

    Mark Stevens <read@my.sig> wrote:[color=blue]
    > I am having problems with double quotes inside a post variable. The
    > code below illustrates this. If the user enters non-quoted text then
    > the code works OK. If "Hello" is entered then I get $some_text equal
    > to \"Hello\". What I want is the actual text that the user entered
    > and not the processed version.[/color]

    special characters are escaped by a backslash (\) upon form submission.
    you can remove the backslashes by

    $some_text = stripslashes($s ome_text);

    check out the stripslashes function in the manual for more information
    and related functions.

    regards,
    steven.

    Comment

    • Mark Stevens

      #3
      Re: Input, POST and double quotes

      On Sat, 14 Feb 2004 12:05:14 +0000 (UTC), steven mestdagh
      <steven.mestdag h@esat.kuleuven .REMOVE-THIS.ac.be> wrote:
      [color=blue]
      >special characters are escaped by a backslash (\) upon form submission.
      >you can remove the backslashes by
      >
      >$some_text = stripslashes($s ome_text);[/color]

      Thanks, knew there had to be simple answer.

      Cheers,
      Mark
      --
      |\ _,,,---,,_ A picture used to be worth a
      ZZZzzz /,`.-'`' -. ;-;;, thousand words - then along
      |,4- ) )-,_. ,\ ( `'-' came television!
      '---''(_/--' `-'\_)

      Mark Stevens (mark at thepcsite fullstop co fullstop uk)

      Comment

      • Andy Hassall

        #4
        Re: Input, POST and double quotes

        On Sat, 14 Feb 2004 11:49:36 +0000, Mark Stevens <read@my.sig> wrote:
        [color=blue]
        >I am having problems with double quotes inside a post variable. The
        >code below illustrates this. If the user enters non-quoted text then
        >the code works OK. If "Hello" is entered then I get $some_text equal
        >to \"Hello\". What I want is the actual text that the user entered
        >and not the processed version.[/color]

        You've got magic_quotes_gp c turned on. If possible, turn it off. If not, use
        stripslashes().

        --
        Andy Hassall <andy@andyh.co. uk> / Space: disk usage analysis tool
        <http://www.andyh.co.uk > / <http://www.andyhsoftwa re.co.uk/space>

        Comment

        • David Jackson

          #5
          Re: Input, POST and double quotes

          Mark Stevens <read@my.sig> wrote in message news:<232s205s9 m7r2smpf9p3rjq3 13udnbp87q@4ax. com>...[color=blue]
          > I am having problems with double quotes inside a post variable. The
          > code below illustrates this. If the user enters non-quoted text then
          > the code works OK. If "Hello" is entered then I get $some_text equal
          > to \"Hello\". What I want is the actual text that the user entered
          > and not the processed version.[/color]

          Take a look at stripslashes():


          David

          Comment

          Working...