I am getting this error when loading the webpage:
Notice: Undefined index: bandselection in /public/sites/www.transport-dealer.com/commercialequipmentfinder/index.php on line 203
Notice: Undefined index: bandselection2 in /public/sites/www.transport-dealer.com/commercialequipmentfinder/index.php on line 204
When i press submit it will show the correct data, is there anyway to make sure the data in the "seleccted"part of the form is already been filtered and shown
HTML:
<form method="post" action="index.php">
<label>
<select name="bandselection" id="bandselection">
<option value="1990" selected="selected">1990</option>
<option value="2006">2006</option>
<option value="2005">2005</option>
<option value="2004">2004</option>
</select>
<select name="bandselection2" id="bandselection2">
<option value="2015" selected="selected">2015</option>
<option value="2006">2006</option>
<option value="2005">2005</option>
<option value="2004">2004</option>
</select>
</label>
<label>
<input type="submit" name="Submit" value="Submit" />
</label>
</form>
PHP:
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$bandselection = $_POST['bandselection'];
$bandselection2 = $_POST['bandselection2'];
$sql = "SELECT ID, link, link_image, modelyear, brand, city, price, description, country, type FROM semi_trailer_curtainsider WHERE modelyear BETWEEN '" . $bandselection ."' AND '" . $bandselection2 ."' AND brand = 'Samro'";