Reputation: 2187
While echoing a form from PHP with some predefined value retrieved from file from php i have come across a trouble.
i can see those predefined values in both input boxes as expected that is Content and Title of the article.
But whenever i click on the submit the Content part of form is not getting submitted.
when i do print_r($_REQUEST); i only see following o/p Array ( [action] => edit_art [art_id] =>11 $art_id [title] => TCS [agree] => on )
when i don't provide predefined value for Content input box (textarea) it is getting submitted with whatever i type in it.
my code is as follows
echo '<form action="art_action.php?action=edit_art&art_id=$art_id" method="post"><br />
<p><b>Article Title</b></p>
<input type="text" name="title" **value='.$art_title.'**/><br />
<span id="title_check"></span><br />
<p><b>Content</b></p><br />
<textarea cols="75" rows="20" **value='.$content.'** name="content"></textarea><br />
<span id="content_check"></span>
<div class="content" ><input type="checkbox" name="agree" style="margin-right:10px"/>Agree Terms and Conditions first.<span id="agree_check"></span><br />
<input type="button" onclick="varify_and_post_article(this.form)" Value="Post Article"/><br />
</form>';
Please help me out. Thanx in advance !!
Upvotes: 2
Views: 330
Reputation: 1710
You may encode variables inside brackets.
ie:
echo "<input value={$variable} />"
or more well-formed
echo "<input value='{$variable}' />"
Upvotes: 0
Reputation: 76890
A textarea has no value
attribute, you should put the $content
inside the tags
echo '<textarea cols="75" rows="20" name="content">'.$content.'</textarea>'
Upvotes: 5