Jump to content

[SOLVED] Echoing back form input for user verification put's a "\" where a " ' &q


alconebay

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.