Hi. I’m new to this forum and this is my first post. That being said. I’m running into an issue where I’m using multiple “If” statements. After the tree of if statements, I have an “Else” statement. The way it’s suppose to work is If a condition is met, then the script stops. Let me give an example. We’re taking values from a submitted form
[php]
If ($_GET[‘device’] === “”)
{
echo ‘ERROR. You did not enter any data into the DEVICE field. Please make sure all fields have values.’;
echo ‘
’;
}
if ($_GET[‘employee’] ==="")
{
echo ‘ERROR. You did not enter any data into the EMPLOYEE field. Please make sure all fields have values.’;
echo ‘
’;
}
if ($_GET[‘datepicker1’] === “”)
{
echo ‘ERROR. You did not enter any data into the STARTING DATE field. Please make sure all fields have values.’;
echo ‘
’;
}
if ($_GET[‘timepicker1’] === “”)
{
echo ‘ERROR. You did not enter any data into the STARTING TIME field. Please make sure all fields have values.’;
echo ‘
’;
}
Else {
Connect to the database and write our values to the database. Last but not least, return a success confirmation message.
}
[/php]
The problem is, even if a field is detected blank, the error page warns the user that it’s blank, however it still executes the “Else” statement. The way I’m wanting it to function is, If a field is detected blank, then the user receives the error and the script STOPS. I know it’s something simple. This is just one of those tiny things that has me pulling my hair out. Any help?