【发布时间】:2012-09-13 18:11:20
【问题描述】:
我有一个 php 表单(要遵循的代码),带有一个运行 JSON-events.php 作为其 action (method = POST) 的提交按钮。在 JSON 事件代码中,我正在测试表单是否已使用 if (!empty($_POST)) 提交。我的问题是 JSON 事件代码似乎无法识别 $_POST。
这是表单端代码部分。
<div class="simple_overlay" id="searchform">
<form id="myform" class = "cols" action="json-events.php" method="post" >
<h3>Search</h3>
<p>
<label>address/postcode *</label>
<input type="address" id="searchaddress" />
</p>
<p>
<label for="amount">maximum distance:</label>
<input type="text" id="amount" value="5 miles" style=" border:0; color:#43a8c4; font-weight:bold;" />
</p>
<div id="slider-range-min" style="width:130px; margin-left:4px; margin-bottom:20px"></div>
<p id="terms">
<label>Category 1</label>
<input name="cat1" type="checkbox" value="1" checked="checked"/>
</p>
<p id="terms">
<label>Category 2</label>
<input name="cat2" type="checkbox" value="1" checked="checked"/>
</p>
<p id="terms">
<label>Category 3</label>
<input name="cat3" type="checkbox" value="1" checked="checked"/>
</p>
<p id="terms">
<label>Category 4</label>
<input name="cat4" type="checkbox" value="1" checked="checked"/>
</p>
<p id="terms">
<label>Category 5</label>
<input name="cat5" type="checkbox" value="1" checked="checked"/>
</p>
<p id="terms">
<label>Category 6</label>
<input name="cat6" type="checkbox" value="1" checked="checked"/>
</p>
<p id="terms">
<label>Category 7</label>
<input name="cat7" type="checkbox" value="1" checked="checked"/>
</p>
<p id="terms">
<label>Category 8</label>
<input name="cat8" type="checkbox" value="1" checked="checked"/>
</p>
<p id="terms">
<label>Category 9</label>
<input name="cat9" type="checkbox" value="1" checked="checked"/>
</p>
<p id="terms">
<label>Category 10</label>
<input name="cat10" type="checkbox" value="1" checked="checked"/>
</p>
<p>
<input type="hidden" name="searchlat" id="searchlat"/>
</p>
<p>
<input type="hidden" name="searchlong" id="searchlong" />
</p>
<input type="submit" name="search" id="search"/>
<input type="button" value="Check Address" onclick="codeAddressSearch()"/>
<button type="reset">Reset</button>
</form>
</div>
这是 JSON 的顶部...
if (!empty($_POST)) {
非常感谢任何帮助
【问题讨论】:
-
等等....你并不是说字符串文字
"if (!empty($_POST)) {"是相关 JSON 对象的一部分,对吧? -
'top part of the JSON' 没有意义,那是 php.ini 的一行。尝试将 $_POST 数组的 var_dump 作为脚本的第一行,看看是否有任何事情通过
-
你在说什么JSON
-
其实我在这里没有看到任何 JSON 证据,看起来像一个普通的 HTML 表单标签,带有普通的提交按钮,但这不影响问题,尝试
var_dump($_POST);看看包含什么数组跨度> -
抱歉有点含糊......
if (!empty($_POST)) {是 JSON-events.php 中的一行,它旨在确保已按下提交按钮以确定运行哪个 JSON。我省略了 JSON 以保持简短。