Exception handling in form
Posted: Tue Jul 27, 2010 11:10 pm
I need to compare a select menu (min) with another select menu (max), and if min is more than max I want an exception handling for this. Where do I put the code?
Ex:
I tried this code but it doesn't work:
Ex:
Code: Select all
$rent_min = $_POST["rent_min"];
$rent_max = $_POST["rent_max"];
if (isset($_POST['submit']))
{ // if page is submitted
}
<form method="post" name="f1" action="search_have.php" target="TITLE" enctype="multipart/form-data">
<select name="rent_min" id="rent_min" class="variablewidth norightmargin">
<option selected="selected" value="0">0</option>
<option value="500">500</option>
</select>
<select name="rent_max" id="rent_min" class="variablewidth norightmargin">
<option selected="selected" value="0">0</option>
<option value="500">500</option>
</select>
</form>
Code: Select all
<form method="post" name="f1" action="<?php if ($rent_min < $rent_max) { echo "search_have.php"; } else { echo "Min rent can't be more than Max rent"; echo $_SERVER['PHP_SELF']; } ?>" target="TITLE" enctype="multipart/form-data">