<?php /*--- function: make_three_value_response purpose: expects nothing, returns nothing, and creates a response that responds to the submitted form with the user's at-least-two-of entered color, flavor, and song by: Sharon Tuttle last modified: 2024-04-23 ---*/ function make_three_value_response() { ?> <h1> quick'n'sleazy response to three_value's form </h1> <?php // CHECKING the passed values (because application // tier MUST do this, no matter how much // client-side checking is done -- anyone anywhere // can try to LEAD to here...!) if (! ( ( ($_POST["color"] != "") && ($_POST["flavor"] != "") ) || ( ($_POST["color"] != "") && ($_POST["song"] != "") ) || ( ($_POST["flavor"] != "") && ($_POST["song"] != "") ) ) ) { ?> <p id="errors"> MUST enter values for at least TWO of color, flavor, and/or song! </p> <form action="<?= htmlentities($_SERVER['PHP_SELF'], ENT_QUOTES) ?>" method="get"> <input type="submit" value="try again" /> </form> <?php } else { ?> <p> form's contents: </p> <ul> <?php if (array_key_exists("color", $_POST)) { $color = htmlspecialchars(strip_tags($_POST["color"])); ?> <li> Color: <?= $color ?> </li> <?php } if (array_key_exists("flavor", $_POST)) { $flavor = htmlspecialchars(strip_tags($_POST["flavor"])); ?> <li> Flavor: <?= $flavor ?> </li> <?php } if (array_key_exists("song", $_POST)) { $song = htmlspecialchars(strip_tags($_POST["song"])); ?> <li> Song: <?= $song ?> </li> <?php } ?> </ul> <form action="<?= htmlentities($_SERVER['PHP_SELF'], ENT_QUOTES) ?>" method="get"> <input type="submit" value="done" /> </form> <?php } } ?>