hi,
i am trying to do this on the result page which doesn't work,
if($loan < 150000)
{
}
else if($loan < 250000)
{
}
else
{
}
whatever value i place, it just evaluate to the first if.
i tried other methods like settype, casting it, even intval($loan), it just won't work...
any ideas? i need to compare tha value the user inputted on the form,
many thanks.
user submits a form with the value of textfield being 15000
Moderator: General Moderators
What is the value
What is the value of loan?
Try echoing out loan(if you haven't already) to make sure that it aleast laon has a value.
It is possible that loan isn't being passed back correctly to the page.
phpScott
Try echoing out loan(if you haven't already) to make sure that it aleast laon has a value.
It is possible that loan isn't being passed back correctly to the page.
phpScott
Code: Select all
<html>
<body>
<?php
if(isset($_POST['loan']))
{
if($_POST['loan'] < 150000)
{
echo 'less than 150k';
}
else if($_POST['loan'] < 250000)
{
echo 'less than 250k';
}
else
{
echo 'more than or 250k';
}
}
?>
<form method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>">
<input type="text" name="loan" id="loan" /><label for="loan">loan</label><br />
<input type="submit" />
</form>
</body>
</html>hello volka,
it works! but i hope you don't mind, can you explain what happened there with the $_POST thing?
also, the php sdk states that we can just use the comparison operator and php will automatically convert variables to ints if it's a string.. but how come it doesn't work? hmm.., maybe this is where _POST comes in..
anyway, hoping for your explanation.
many thanks,
it works! but i hope you don't mind, can you explain what happened there with the $_POST thing?
also, the php sdk states that we can just use the comparison operator and php will automatically convert variables to ints if it's a string.. but how come it doesn't work? hmm.., maybe this is where _POST comes in..
anyway, hoping for your explanation.
many thanks,
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK