Thread: possible BUG???

    #1
  1. No Profile Picture
    AlexDG
    Guest
    Devshed Newbie (0 - 499 posts)
    Hi! I donno what I've found but I can't solve it.

    <form method="post" action="1.php3">
    <input type="text" name="test" value="<? echo $test ?>">
    <input type="submit">
    </form>


    If I type any characters like ', , " (which usually displays in the code like ', , ") and submit a form, all those characters are getting replaced by ', and ".

    example:

    ' > submit form
    result: ' > submit again
    result: ' > submit again
    result: '

    does anyone have/had such a problem?

    Thank you
  2. #2
  3. No Profile Picture
    rod k
    Guest
    Devshed Newbie (0 - 499 posts)
    You must have magic quotes on. You can either turn them off (see manual) or change this line:

    <input type="text" name="test" value="<? echo $test ?>">

    to this:

    <input type="text" name="test" value="<? echo stripslashes($test) ?>">
  4. #3
  5. No Profile Picture
    AlexDG
    Guest
    Devshed Newbie (0 - 499 posts)
    Thank a lot man!! =)
  6. #4
  7. No Profile Picture
    rod k
    Guest
    Devshed Newbie (0 - 499 posts)
    Ooops, I made a mistake. If a " exists in $test, then the value will not parse right as HTML will interpret that " as the closing " of value.

    You need to do one more operation:

    <input type="text" name="test" value="<? echo htmlspecialchars(stripslashes($test)) ?>">

    htmlspecialchars() converts &,",<,> to &amp;,&quot;,>,&lt respectively so it will display properly.

Similar Threads

  1. Help to solve this bug with Javascript and Opera Cache Managing
    By mapg in forum JavaScript Development
    Replies: 0
    Last Post: January 19th, 2004, 09:11 PM
  2. Replies: 0
    Last Post: January 19th, 2004, 07:42 PM
  3. IE positioning bug and its solution
    By delerious in forum HTML Programming
    Replies: 3
    Last Post: December 23rd, 2003, 04:42 AM
  4. Replies: 1
    Last Post: September 24th, 2003, 09:20 AM
  5. Very strange bug, vars ignored.
    By Kristten in forum PHP Development
    Replies: 7
    Last Post: June 25th, 2003, 12:26 PM

IMN logo majestic logo threadwatch logo seochat tools logo