# PHP function does not validate

**URL:** <https://forum.kirupa.com/t/php-function-does-not-validate/331768>\
**Category:** programming\
**Created:** [October 16, 2013, 10:12am UTC](https://forum.kirupa.com/t/php-function-does-not-validate/331768 "2013-10-16T10:12:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![last](https://avatars.discourse-cdn.com/v4/letter/l/ecae2f/32.png) [@last](https://forum.kirupa.com/u/last)\
**Post date:** [October 16, 2013, 10:12am UTC](https://forum.kirupa.com/t/php-function-does-not-validate/331768/1 "2013-10-16T10:12:52Z")

</div>

[LEFT][COLOR=#000000][FONT=Arial]I have created a simple php page that needs to validate if the amount entered is greater than 100 or must return an error. My function though does not get called when psoting and the amount is less than 100

```php

<html>
<head></head>
<title></title>
<style>
.error {color: #FF0000;}
</style>
<body>

<?php
function test_input($data)
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
 $amountErr="";
$amount="";
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
if (($_POST["amount"])>100)
{$amountErr = "Value must be equal or greater than 100";}
else
{
    $amount = test_input($_POST["amount"]);}
}

?>
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<p><span class="error">*required field.</span></p>

Amount:<input type="text" name="amount"/>
<span class="error">*<?php echo $amountErr;?></span>

<input type="submit" value="Pay"/>
</form>

</body>
</html>

```

[/FONT][/COLOR][/LEFT]
