Click to See Complete Forum and Search --> : apostrophes in input box wreak havoc in $_Post varialb


mparker1113
11-03-2007, 02:05 PM
I am sure that the solution to this is easy, but it has been escaping me. I have the user input some values then i will redisplay the values if i have to (they have an entry error). If the user inputs an apostrophe, then the post variable cuts off at the entered apostrophe and adds a back slash. (so if user input mike's, the post variable is mike/.

This is an example of my code:


<td>Last Name:</td><td><input type='text' name='frm_Lname' value='<? echo addslashes($_POST['frm_Lname']) ; echo (str_replace($_POST['frm_Lname'],"'",""))?>'></td>


How do i make it so that users can enter apostrophes? am i missing something else for safety sake, too? I am using version 4.xx.

Thank you for any input.

scragar
11-03-2007, 02:14 PM
http://uk3.php.net/manual/en/function.htmlspecialchars.php

that any help?

mparker1113
11-03-2007, 05:33 PM
http://uk3.php.net/manual/en/function.htmlspecialchars.php

that any help?

not a bad article. not what i needed, but i got it solved after some manipulation.

thanks

NogDog
11-03-2007, 05:59 PM
urlencode()

E.g.:

$url = "http://blahblahblah/foobar.php?value=" . urlencode($_POST['name']);