phpluke Posted August 24, 2009 Share Posted August 24, 2009 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="' . $_POST[item1] . '">'; ?> 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! Link to comment https://forums.phpfreaks.com/topic/171620-passing-php-form-variable-where-user-has-entered-quotation-marks/ Share on other sites More sharing options...
Catfish Posted August 24, 2009 Share Posted August 24, 2009 Option 1: Do what you have done, then use ltrim() and rtrim() to remove the quotes on either end. Option 2: Use urlencode() on $_POST['item1'] Link to comment https://forums.phpfreaks.com/topic/171620-passing-php-form-variable-where-user-has-entered-quotation-marks/#findComment-904990 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.