alconebay Posted April 8, 2008 Share Posted April 8, 2008 I have a form that users fill and and the form action sends it to a mysql database. But on the action page I echo back everything the user input and if the user used apostrophes (or possibly other special characters) they get echoed back with a backslash before it. How do I stop this? Here is some of the code: $username=$_POST['UserName']; $puppyname=$_POST['puppyname']; $description=$_POST['Description']; Username: <? echo $username; ?> Puppy Name: <? echo $puppyname; ?> Description: <? echo $description; ?> If I type this in the form: Username: alconebay Puppy Name: Benno's Von Eveman Puppy Description: Puppy from Benno's Von Eveman. This is what I see on the confirmation page: Username: alconebay Puppy Name: Benno\'s Von Eveman Puppy Description: Puppy from Benno\'s Von Eveman. This could confuse people and make them think they have some typo's in the form. How do I stop this from happening? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/100157-solved-echoing-back-form-input-for-user-verification-puts-a-where-a-q/ Share on other sites More sharing options...
craygo Posted April 8, 2008 Share Posted April 8, 2008 If you are inserting the data inta a database you need the backslashes in order to correctly insert the data. if you do not want this you can set magic_quotes_gpc to off in the php.ini file or you can just use stripslashes to remove them before you echo them out. $description=stripslashes($_POST['Description']); Ray Quote Link to comment https://forums.phpfreaks.com/topic/100157-solved-echoing-back-form-input-for-user-verification-puts-a-where-a-q/#findComment-512104 Share on other sites More sharing options...
alconebay Posted April 8, 2008 Author Share Posted April 8, 2008 Thanks, I redefined those variables with that stripslash right before I echoed them back out to the user. Works Great! Thanks Quote Link to comment https://forums.phpfreaks.com/topic/100157-solved-echoing-back-form-input-for-user-verification-puts-a-where-a-q/#findComment-512172 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.