N.N.Ontika N.N.Ontika - 10 months ago 24
HTML Question

Whole value is not passing from input field using POST PHP

I am facing problem to pass data from one page to another using POST method. I want to pass data from the input field name 'keyword' to another PHP page. But it is not passing the complete data but when i print this data in same page using the 'keyword_div' it is showing the complete data.

Div is showing only 10 words:

আয়,গুর,ছুটে,লগন,জীবন,বয়ে, আজ,যায়,করে,চাঁদের

These lines are for passing the data-

print "<input type='hidden' id='keyword' name='keyword' value=". implode(',', extractKeyWords($file)) .">";
Print "<div class='output' name='keyword_div' id='keyword_div'>Keywords: " . implode(',', extractKeyWords($file)) . "<div>";

These lines are for getting the data after form submission-

if (isset($_POST['keyword'])){
$val = $_POST['keyword'];
} echo $val;

But Input is passing 6 words only:


Why I am not getting the whole value? Please help.


You need to put quotes around the value, because there's a space at the beginning of the 7th keyword and that's ending the value attribute.

print "<input type='hidden' id='keyword' name='keyword' value='". implode(',', extractKeyWords($file)) ."'>";

Good HTML style is to put quotes around all attribute values.

If you want to get rid of the whitespaces as well, call trim().

print "<input type='hidden' id='keyword' name='keyword' value='". implode(',', array_map('trim', extractKeyWords($file))) ."'>";