Hello All,
Can somone correct me what I am doing wrong here. Maybe I need a break from the staring at the screen. Here is my code:
however when testing only the Income field, it gives the reverse logic. when I put in 20 it asks me to "Please enter numeric value" like so
Income:20
Expences:
Debt:
Please enter a value
++++++++++++++++++++++
AND when I put in non-numeric it asks me to "Please enter a value" like so:
Income:rewrwer
Expences:
Debt:
Please enter a value
++++++++++++++
I was wondering if anyone can help with this logic
Can somone correct me what I am doing wrong here. Maybe I need a break from the staring at the screen. Here is my code:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml"[/URL] xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title> Finance </title>
<style type="text/css" media="screen">.error {color: red ;} </style>
</head>
<body>
<form action="finance.php" method="post">
<p>Income: <input type="text"
name="income" size="10" /></p>
<p> Expences: <input type="text"
name="expenses" size="10" /></p>
<p> Debt: <input type="text"
name="debt" size="10" /></p>
<input type="submit" name="submit"
value="Calculate" />
</form>
<?php
//flag variable to track success:
$okay = TRUE;
//check to see if there is value in income
if (empty($_POST['income'])) {
print '<p class="error"<The income field is empty. </p>';
} elseif (is_numeric($_POST['income'])){
print '<p class="error">Please enter numeric value </p>';
} else {//Problem
print '<p class="error">Please enter a value </p>';
$okay =FALSE;
}
if ($okay) {
print '<p> </p>';
}
?>
</body>
</html>
however when testing only the Income field, it gives the reverse logic. when I put in 20 it asks me to "Please enter numeric value" like so
Income:20
Expences:
Debt:
Please enter a value
++++++++++++++++++++++
AND when I put in non-numeric it asks me to "Please enter a value" like so:
Income:rewrwer
Expences:
Debt:
Please enter a value
++++++++++++++
I was wondering if anyone can help with this logic