This program is supposed to show a dropdown selection for the user, with an output of a response from that particular choice using switch statement in php. I can't get my if statement to work though. Can someone help me please? Thank you all.
<!doctype html>
<html>
<head>
<title>Program 2</title>
</head>
<body>
<form action="<?php $PHP_SELF; ?>" method="post">
<select name="pick">
<option value="regular">I am a regular customer</option>
<option value="friend">From a friend</option>
<option value="television">On television</option>
<option value="online">In an online search</option>
</select>
<input type="submit" value="Submit Form"><br>
</form>
<?php
$choice = $_POST['pick'];
if($choice($_POST['pick']) echo "Excellent. We love our regular customers!";) {
} else {
switch($choice) {
case 'regular':
echo "Excellent. We love our regular customers!";
break;
case 'friend':
echo "Please thank your friend for us.";
break;
case 'television':
echo "We are glad to hear our TV ads are working.";
break;
case 'online':
echo "We work hard to be found on Google.";
break;
}
}
?>
Aucun commentaire:
Enregistrer un commentaire