Hi all. I have this problem within the form. I take data from a DB and pass it on using POST. Considering that I fetched array correctly, the following code has the following output:


echo $value[0];
//echoes Hello World


echo "<input type=hidden name=value value=".$value[0].">";
//when echoed in the form action page as $_POST, it echoes Hello only


I don't understand why I can't pass the entire Hello World phrase using hidden inputs. I also tried:
a) closing the input with the </input> tag. //no effect
b) closing php and using plain html as in:
?> <input type=hidden name=value value= <?php echo $value[0]; ?> > <?php //no effect

Recommended Answers

All 2 Replies

Because your tag attributes aren't enclosed within quotes, as per html specifications.

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

Or this:

echo "<input type='hidden' name='value' value='{$value[0]}' />";
commented: Dead on right answer +3

Thank you very much pritaeas. This has certainly solved the problem. Going to close now.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.