[英]$_POST doesn't work for PHP post. ISSET reports that no such value was forwared via post method?
我有一个用于评论部分的表格。 在这里,每个评论都有唯一的ID。 但是,注释不会转发到动作PHP表单。
注释代码:
echo '<form action="interact.php" method="post">';
$new_refreshed_ID = 'uni_story_ID_' . $row['ID'] . '_comment_ID_' . $cache_ready_new_comment_ID;
echo '<textarea name="' . $new_refreshed_ID . 'rows="12" cols="70"></textarea>';
echo '<button type="submit">Submit</button>';
echo '</form>';
$_SESSION['assoc'] = $row['ID'];
$_SESSION['cache_comment_details'] = $new_refreshed_ID;
我接收请求的代码:interact.php:
<?php
session_start();
$assoc = $_SESSION['assoc'];
$get_comment = $_SESSION['cache_comment_details'];
if(isset($_POST[$get_comment])) {
echo "yea!";
} else {
echo "no!";
die();
}
我在interact.php中找不到任何信息,这意味着没有数据被转发。 怎么会这样?
顺便说一句评论ID是这样的(例如):
uni_story_ID_4_comment_ID_17
我确实检查了$ new_refreshed_ID。 它会根据需要正确显示所有值。 我确实在两个PHP文件中都启动了会话。
echo '<textarea name="' . $new_refreshed_ID . 'rows="12" cols="70"></textarea>';
您需要像这样关闭textarea的名称:
echo '<textarea name="' . $new_refreshed_ID . '" rows="12" cols="70"></textarea>';
编辑:最好不要使用不需要的php(以避免这些),您可以这样做:
<textarea name="<?php print $new_refreshed_ID;?>" rows="12" cols="70"></textarea>
请注意,这是一个示例,我只打印php真正需要的内容,否则我将使用html :)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.