In this project, you modify a nested if statement so it instead uses a compound conditional expression. You use logical operators such as the || (or) and && (and) operators to execute a conditional or looping statement based on multiple criteria.

1. Create a new document in your text editor.

2. Type the < !DOCTYPE> declaration, < html> element, document head, and < body> element. Use the strict DTD and "Gas Prices" as the content of the < title> element.

3. Create a script section in the document body that includes the following variable declaration and nested if statement:

< ?php
$GasPrice = 1.57;
if($GasPrice > 1) {
if($GasPrice < 2) {
echo "< p>Gas prices are between $1.00 and $2.00.< /p>";
}
?>

4. Modify the nested if statement you created in the previous step so it uses a single if statement with a compound conditional expression. You need to use the && (and) logical operator.

5. Add an else clause of the if statement that prints "Gas prices are not between $1.00 and $2.00" if the compound conditional expression returns false.

6. Save the document as GasPrices.php in the Projects directory of Chapter 4.

7. Create a new document in your text editor.

8. Type the < !DOCTYPE> declaration, < html> element, document head, and < body> element. Use the strict DTD and "Gas Prices" as the content of the < title> element.

9. Add to the document body a form contain a single text box and a Submit button. Use the text box to enter a gasoline price that you can submit to the GasPrices.php script. Add the appropriate code to the form that allows you to submit the form to the GasPrices.php document with a method of "get".

10. Save the document as GasPrices.html in the Projects directory for Chapter 4, and then close it in your text editor.

11. Return to the GasPrices.php document in your text editor and modify the script so it uses the $_GET autoglobal to refer to the form variable.

12. Save GasPrices.php and then close them in your text editor.

13. Open the GasPrices.html file in your Web browser by entering the following URL: http://localhost/PHP_Projects/Chapter.04/Projects/GasPrices.html. Test the script by entering a price in the text box and click the Submit button.

14. Close your Web browser window.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.