Skip to content

Instantly share code, notes, and snippets.

@phpfiddle
Created November 2, 2020 22:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phpfiddle/b3997ed40d37989cef9809fbd03328f3 to your computer and use it in GitHub Desktop.
Save phpfiddle/b3997ed40d37989cef9809fbd03328f3 to your computer and use it in GitHub Desktop.
[ Posted by Amar Beslija ] How to use black lists. https://lab387.com
<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