Jump to content

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


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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.