Created
November 2, 2020 22:16
-
-
Save phpfiddle/b3997ed40d37989cef9809fbd03328f3 to your computer and use it in GitHub Desktop.
[ Posted by Amar Beslija ] How to use black lists. https://lab387.com
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Black List</title> | |
<meta charset="utf-8"> | |
</head> | |
<body> | |
<form action="" method="POST"> | |
<label>Choose your color:</label> | |
<select name="color"> | |
<option value="red">Red</option> | |
<option value="blue">Blue</option> | |
<option value="green">Green</option> | |
<option value="black">Now it is a good option</option> | |
</select> | |
<input type="submit" value="Send your color"> | |
</form> | |
<?php | |
$colors = ["red", "blue", "green"]; | |
if(isset($_POST["color"])){ | |
$color = $_POST['color']; | |
$color = htmlspecialchars($color); | |
if(!in_array($color, $colors)){ | |
// Proceed with data processing | |
echo "Color " . $color . " is good!"; | |
}else{ | |
// Do not proceed with data processing | |
echo "Color " . $color . " is not good!"; | |
} | |
} | |
?> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment