im working on having php validate negative values, numeric and non numeric and empty values in a value.
i need php to display error message if a value is negative, empty, non-numeric
im also having an issue with not getting values from my html form in $_POST
$first = $_POST['first'];
$second = $_POST['second'];
$operation = $_POST['operation'];
and in my form the names of each value is correctly spelled
for negative values i have
if ($first or $second < 0)
{
print("<h2> Error one or more inputs are not negative numbers</h2>");
echo("<a href="calculator.html"></a>");
}
for empty numbers i have
if (empty($first) or empty($second) == true)
{
print("<p> One or more input field is empty </p>");
echo("<a href="calculator.html"></a>");
}
and for a value that is not numeric
if (!is_numeric($first) or !is_numeric($second) == false)
{
print("<h2> Error one or more inputs are not numbers</h2>");
echo("<a href="calculator.html"></a>");
}
my issue is that every time any number is entered i get error messages if its true or false
Aucun commentaire:
Enregistrer un commentaire