我有以下下拉框。我希望能够从此框中选择一个值并使用 Php 将其发送到另一个页面。
这是我当前的 drop dwon box 代码:
版本2:
<form style="margin-top:20px; margin-right:+50px" name="formname" method="post" action="search.php">
<div class="controls controls-row">
<select name="select1" id="select1">
<option value="SelectIsland">Select your island</option>
<option value="stMaarten">St. Maarten</option>
<option value="Aruba">Aruba</option>
<option value="Curacou">Curacou</option>
<option value="StBarths">St. Barths</option>
</select>
<select name="select2">
<option value="SelectLoc">Select your location</option>
<option value="Philipsburg">Philipsburg</option>
<option value="SimpsonBay">Simpson Bay</option>
<option value="Maho">Maho</option>
<option value="Cupecoy">Cupecoy</option>
<option value="Middleregion">Middle region</option>
<option value="MadameEstate">Madame Estate</option>
<option value="StPeters">St. Peters</option>
<option value="DawnBeach">Dawn Beach</option>
</select>
<input type="submit" name="button" class="btn btn-primary" value="Find Restaurant" style="margin-top:-10px; margin-right:0px" />
</div>
<?php
$select1 = $_POST['select1'];
?>
</form>
我正在尝试将 $select1 传递给 search.php,使用这个: $select1 = $_POST['select1'];
但是我得到了以下错误,没有做任何事情:注意:未定义的索引:C:\wamp\www\iLandgrub.com V 1.2\main page\index.php 中的 select1 在第 194 行,在 y index.php 上。
如果我删除 $select1 = $_POST['select1']; 然后它会起作用,但在 search.php 上我没有得到我想要的值。
这是我在 search.php 中的代码:
这同样适用于 select2。我已经在我的 index.php 中没有做任何事情我得到错误未定义的索引。
<?php
if(isset($_POST['select1']) && isset($_POST['select2'])) {
$select1 = $_GET['select1'];
$select2 = $_GET['select2'];
echo $select1;
echo "";
echo $select2;
}
else{
echo "not set";
}
?>
当您转到此页面时,这是 index.php 中的错误。