I have the following drop down box. I want to be able to select a value from this box and using Php sending it to another page.
this is my current code for drop dwon box:
version2:
<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>
I am trying to pass $select1 to search.php, using this: $select1 = $_POST['select1'];
however I get this following error, without doing anything: Notice: Undefined index: select1 in C:\wamp\www\iLandgrub.com V 1.2\main page\index.php on line 194, on y index.php.
If I remove $select1 = $_POST['select1']; then it will work but on search.php I dont get the values I wanted.
this my code in search.php:
the same applies for select2, as well. I am already in my index.php withut doing anything I get the error Undefined index.
<?php
if(isset($_POST['select1']) && isset($_POST['select2'])) {
$select1 = $_GET['select1'];
$select2 = $_GET['select2'];
echo $select1;
echo "";
echo $select2;
}
else{
echo "not set";
}
?>
this is the error in index.php, when you go to this page.