php switch statement using text box
I am trying to use a switch statement to make it so that when that
specific word is typed into the text box it will display the available
models of that car
for example
if the user entered "Volkswagen" it should echo "The available models are
Beetle and Polo"
here is the code i have so far,
<form action="switch.php" method="post">
<input type="text" name="cars" id="cars" />
<input type="submit" />
<?php
$i = $_POST;
?>
<?php
switch ($i) {
case "Volkswagen":
echo "The available models are Beetle and Polo";
break;
case "Renault":
echo "The Available models are Megane and Clio";
break;
case "Land Rover":
echo "The Available models are Range Rover Sport and Defender";
break;
}
?>
</form>
No comments:
Post a Comment