用php提交表单

用php提交表单,php,forms,textarea,Php,Forms,Textarea,--编辑--- 我创建了一个文本框区域,用户可以在其中输入一些数据 基本上,当我按下提交按钮时,它应该保存输入的数据。这是完整的代码,我无法修复它/ 用户条目不会得到更新 <?php if ( $act == "htmlprofile" ) { ?> <div class="contentcontainer"> <div class="contentmboardheaderarea"><img src="images/hea

--编辑--- 我创建了一个文本框区域,用户可以在其中输入一些数据

基本上,当我按下提交按钮时,它应该保存输入的数据。这是完整的代码,我无法修复它/

用户条目不会得到更新

    <?php
if ( $act == "htmlprofile" ) {


 ?>


    <div class="contentcontainer">
  <div class="contentmboardheaderarea"><img src="images/header.png" />
<div style=”word-wrap: break-word”><div class="contentheadertext"><?php echo "$hlang2"; ?></div></div></div>
  <div class="contentheading">
      <form id="htmlform" name="htmlform" method="post" action="options.php?act=htmlsubmit">
    <div class="contentheading4">
    <?php echo "$olang15"; ?></div>
</div>
    <div class="contentmboardlistarea2"><textarea id="htmlprofile" name="htmlprofile" cols="33" rows="10"><?php echo $qry2[htmlprofile];?>
 </textarea></div></form>
  <div class="contentbuttonarea">
    <div class="contentbutton1" onClick="document.location.href = 'profile.php?act=index'";><?php echo "$glang3"; ?></div>
    <div class="contentbutton2" onClick="document.forms['htmlform'].submit();"><?php echo "$glang21"; ?></div>
    <div class="contentbutton3"></div>
    <div class="contentbutton4"></div>
    <div class="contentbutton5" onClick="document.location.href = 'help.php#htmlprofile'";><?php echo "$glang5"; ?></div>
  </div>
</div>

<?php
}
?>


<?php
if ( $act == "htmlsubmit" ) {

$save ='Profile updated successfully';  
$query4 = "UPDATE members SET htmlprofile = '$htmlprofile' WHERE username = '$myuser'";
mysql_query($query4);
?>


文本区域中没有
属性
您必须在
文本之间输入内容

请参阅以供参考

应该是这样的

请参考此答案,您的div
contentheadertext
不包含在
中,因此如果您在那里有输入,则不会包含在表单提交中


要解决此问题,请将开头的
标记移到更高的位置,以便它包含所有输入。

提交工作正常。但是您没有定义post数据的变量。文本区域没有“价值”。如果回音中不需要固定字符串,请不要使用“

请尝试以下操作:

<textarea id="htmlprofile" name="htmlprofile" cols="33" rows="16"><?php echo htmlspecialchars($_POST['htmlprofile']); ?></textarea>

如果您试图在HTML中使用php变量,只需使用echo$myvariable;此处不需要引号。但是如果您试图回显字符串,请使用类似echo'mystring'的引号

此外,当您试图传递一些值作为表单提交的一部分时,所需的值应该在标记之间


如果您想在文本区域内显示任何值,请记住它没有“value”属性。因此,请这样编写代码:要显示的值

我只是想知道您的
submit
按钮在哪里(?)它可能没有提交数据,因为POST操作要转到options.php。@Fred-我假设它是由
document.forms['htmlform']调用的。submit()
当用户到达页面时,它的确切内容是什么(我看到
)@andrewsi我也这么认为,但我没有看到任何其他JS支持它。我已经提到了关于
textarea
你的答案与我的答案有什么不同??在profile.php中有一个变量叫做“$content”当我开始测试我的答案时,没有其他答案。我还提到了其他一些事情。
<textarea id="htmlprofile" name="htmlprofile" cols="33" rows="16"><?php echo htmlspecialchars($_POST['htmlprofile']); ?></textarea>