Exception handling in form

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
md7dani
Forum Newbie
Posts: 13
Joined: Fri Oct 23, 2009 1:55 am

Exception handling in form

Post by md7dani »

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:

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>
I tried this code but it doesn't work:

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">
Post Reply