在用从PHP文件中检索到的一些预定义值回显来自PHP的表单时,我遇到了一个问题。
我可以在两个输入框中看到这些预定义的值,即文章的内容和标题。
但每当我点击提交时,表单的内容部分都不会被提交。
当我打印_r($_REQUEST)时;我只看到下面的o/p数组([action]=>edit_art[art_id]=>11$art_id[title]=>TCS[agreat]=>打开)
当我没有为内容输入框(文本区域)提供预定义的值时,无论我在其中键入什么,它都会被提交。
我的代码如下
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>';
请帮帮我。提前感谢!!
文本区域没有value
属性,您应该将$content
放在标签中
echo '<textarea cols="75" rows="20" name="content">'.$content.'</textarea>'
您可以将变量编码在括号内。
即:
echo "<input value={$variable} />"
或更多形成良好的
echo "<input value='{$variable}' />"