我正在尝试将 HTML 发布到另一个 php 并且 $_POST 数组为空。
<?php for($i = 0;$i<count($plans);$i++) { ?>
<form id="<?php echo "cart-form-" . $i ?>" method="post" action="<?php echo BASE_URL; ?>browse">
<div class="four columns">
<input type="hidden" name="id" id="id" value="<?php echo $plans[$i]->id; ?>">
<ul class="pricing-table">
<li class="header item"><?php echo $plans[$i]->header ?></li>
<li class="item"><?php echo $plans[$i]->price; ?></li>
<li class="item"><?php echo $plans[$i]->description; ?></li>
<li class="pricing-table-button"><button class="std-button" type="submit">Buy</button></li>
</ul>
</div>
</form>
<?php } ?>
在浏览页面上,我得到了空数组。
print "CONTENT_TYPE: " . $_SERVER['CONTENT_TYPE'] . "<BR />";
$data = file_get_contents('php://input');
print "DATA: <pre>";
var_dump($data);
var_dump($_POST);
print "</pre>";
呈现的 HTML
<form id="cart-form-0" action="/browseselection" method="post">
<div class="four columns">
<input id="id" value="1" name="id">
<ul class="pricing-table">
<li class="header item">Product ABC</li>
<li class="item">$123</li>
<li class="item">5</li>
<li class="pricing-table-button">
<button class="std-button" type="submit">Buy</button>
</li>
</ul>
</div>