首页 文章

表单元素在从PHP回显时未提交

提问于
浏览
2

虽然从PHP回显一个表单并从php中的文件中检索到一些预定义的值,但我遇到了麻烦 .

我可以在预期的两个输入框中看到这些预定义值,即文章的内容和 Headers .

但每当我点击提交时,表单的内容部分都没有提交 .

当我做print_r($ _ REQUEST);我只看到以下o / p数组([action] => edit_art [art_id] => 11 $ art_id [title] => TCS [agree] => on)

当我没有为内容输入框(textarea)提供预定义值时,它将被提交,无论我输入什么内容 .

我的代码如下

echo '<form  action="art_action.php?action=edit_art&art_id=$art_id" method="post">
<p><b>Article Title</b></p> <input type="text" name="title" **value='.$art_title.'**/>
<span id="title_check"></span>
<p><b>Content</b></p>
<textarea cols="75" rows="20" **value='.$content.'** name="content"></textarea>
<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>
<input type="button" onclick="varify_and_post_article(this.form)" Value="Post Article"/>
</form>';

请帮帮我 . Thanx提前!!

2 回答

  • 5

    textarea没有 value 属性,您应该将 $content 放在标签内

    echo '<textarea cols="75" rows="20" name="content">'.$content.'</textarea>'
    
  • 0

    您可以在括号内编码变量 .

    即:

    echo“<input value = {$ variable} />”

    或者更加完善

    echo "<input value='{$variable}' />"
    

相关问题