Hi everybody,
I’ve been writing a health calculator for a school project for about 2 days now and so far so good it all works fine, untill my teacher told me you could leave fields blank and the calculation would still be performed so I started writing a validation page, but it doesn’t work for even a tiny bit. So I’m asking for your help here.
First you have the page/ form where information is wrote
[code]
input{ width: 200px; } td{ width:150px; text-align:center; border:0px black solid; } Gezondheidstest
Geslacht?
- -
Man
Vrouw
Rookt je? - - nee ja |
Hoeveel uur per week sport je? |
|
||||||||
|
And then the validation page comes (validate.php)
[php]
processing... <?php $sport=$_POST['sport']; $name=$_POST['name']; $weight=$_POST['weight']; $length=$_POST['length']; $smoke=$_POST['smoke']; $age=$_POST['age']; $sex=$_POST['sex']; //Variabelen ophalen uit input formif ($name = '' or $name = 'Typ hier uw naam') {$incorrectName = '<li>Vul je naam in asjeblieft</li>';}
if ($weight = '' or $weight = 'Typ hier uw gewicht in Kg in') {$incorrectWeight = '<li>Vul je gewicht in asjeblieft</li>';}
if ($length = ''or $length = 'Typ hier uw lengte in in centimeter bv. 179') {$incorrectLength = '<li>Vul je lengte in asjeblieft</li>';}
if ($age = '' or $age= 'Typ hier uw leeftijd') {$incorrectAge = '<li>Vul je leeftijd in asjeblieft</li>';}
if ($sex = '') {$incorrectSex = '<li>Vul je geslacht in asjeblieft</li>';}
if ($smoke = '') {$incorrectSmoke = '<li>Vul in of je rookt asjeblieft</li>';}
if ($sport = '') {$incorrectSport = '<li>Vul in hoeveel je ongeveer sport asjeblieft</li>';} //incorrect gegevens aanduiden
if ($name = ""
or
$length = ""
or
$weight = ""
or
$age = ""
or
$smoke = ''
or
$sport = ''
or
$sex = '') {print '<ul>'.$incorrectName.''.$incorrectAge.''.$incorrectLength.''.$incorrectWeight.''.$incorrectSex.''.$incorrectSmoke.''.$incorrectSport.'</ul><br /><a href="gezondheidstest.html">Klik hier om terug te gaan naar het formulier</a>';}
else {
include "calculate.php" ;}
?>
[/php]And then normally the actually calculation (calculate.php) would show, but it isn’t showing at all
[php]
body{ font-size:13pt; font-family:Arial, Helvetica, sans-serif; } .note{ font-size:11pt; font-family:"Times New Roman", Times, serif; font-style:italic; color: #666; } em{ font-size:13pt; font-family:Arial, Helvetica, sans-serif; color:red; } calculate [/php]It’s meant to display errors when field/options are left blank or when a default value isn’t changed (for example the name input). And I know that you’ll most likely think it could’ve been written a lot better but I’m only writing php for 2 days now so please try to miminize comments about this issue.
Hoping for help
Greetings
Yoram