Jump to content

passing php form variable where user has entered quotation marks


phpluke

Recommended Posts

Hi,

 

I was just wondering if someone could possibly help me with the following problem:

 

I have a form which outputs to a text file. The form contains a number of text areas, where respondents are encouraged to leave detailed responses. I have noticed that if a respondent uses quotation marks (e.g. the person told me to "be quiet"), the data is reading the quotation mark as a delimiter, so that the example text above would output as:

 

the person told me to

 

leaving out the "be quiet". However, what I have determined is that it is nothing to do with the outputting of the data to the text file, as it will output quotation marks if the text area questions are on the webpage directly before the PHP script that sends the responses to the text file. Where it doesn't work is when I introduce multiple pages to the form and try to pass the data from page to page as a hidden variable. An example of this code is below:

 

<?php

echo '<input type="hidden" name="item1" value="' . $_POST[item1] . '">';

?>

 

One piece of advice I received was to change that code to the following:

 

<?php

echo '<input type="hidden" name="item1" value=&quot' . $_POST[item1] . '&quot>';

?>

 

This at least captured the entire response, but also added quotation marks at the beginning and end of each user response, such that the example above would now output as:

 

"the person told me to "be quiet""

 

Is there a better way to capture the user's response without having to add the extra set of quotation marks?

 

Any help would be most appreciated! :)

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.