Reputation: 151
I have a hidden input that takes the article name. With a title that has the symbol "&" in it.
<input name="art" type="hidden" id="art" value="<?php echo $rew['art']; ?>"/>
When I submit my form, the $_POST doesn't register the full article title. It only goes up to the point where the & was, and the rest is blank.
I want this: "This is & was."
But I get: "This is ".
How can I make it so that when I submit a form I get the "&" symbol and the remaining context.
I'm also searching in the database as well. My problem right now is getting the remaining parts of the title after "&"
Upvotes: 1
Views: 265
Reputation: 14983
You need to escape HTML entities via the htmlspecialchars
function:
<input name="art" type="hidden" id="art" value="<?php echo htmlspecialchars($rew['art']); ?>"/>
Based on discussion in the comments below, you also need to escape the ampersand in the URL you're generating for an Ajax request. You can do this in JavaScript with the encodeURIComponent
function:
var dataString = '&topic' + encodeURIComponent(topic);
Upvotes: 2