- Impact
- 8
Hey,
I have the following code in a script:
What i want it to do is display a message when a value isnt entered into a field but i want to display an error for each missed field at once and if they arent there show the order form again instead of running the rest of the code. However with the code above if the first one exists it doesnt check for the rest of the statements and there must be an easier way than copying the next two into the else section?
Im learning php so i just want to know as i will probably use this in a future script.
Thanks
I have the following code in a script:
PHP:
<?php
if ( empty($tireqty) == 1 ) {
echo '<font color=#ff0000>';
echo 'You did not enter an amount for tires <br /><br />';
echo '</font>';
if ( empty($oilqty) == 1 ){
echo '<font color=#ff0000>';
echo 'You did not enter an amount for oil <br /><br />';
echo '</font>';
if ( empty($sparkqty) == 1 ){
echo '<font color=#ff0000>';
echo 'You did not enter an amount for spark plugs <br /><br />';
echo '</font>';
include 'orderform.html';
exit;
}
include 'orderform.html';
exit;
}
include 'orderform.html';
exit;
}
?>
What i want it to do is display a message when a value isnt entered into a field but i want to display an error for each missed field at once and if they arent there show the order form again instead of running the rest of the code. However with the code above if the first one exists it doesnt check for the rest of the statements and there must be an easier way than copying the next two into the else section?
Im learning php so i just want to know as i will probably use this in a future script.
Thanks







