simple php problem (probably)
Posted: Sat Feb 27, 2010 3:13 pm
Hi there, I'm new to PHP and this is just a practise script... not important but if anyone could point out where I'm going wrong I'd appreciate it. Basically the script doesn't seem to do anything... doesn't get any error messages either...
Thanks
Code: Select all
<?php
if (isset($_GET['submit'])) {
$sloth = $_GET['Sloth'];
$llama = $_GET['Llama'];
$monkey = $_GET['Monkey'];
$giraffe = $_GET['Giraffe'];
$gorilla = $_GET['Gorialla'];
$giraffe = $_GET['Giraffe'];
$whale = $_GET['Whale'];
$moth = $_GET['Moth'];
if (isset($_GET['sloth'])) {
echo "Sloth's are boring";
} elseif (isset($_GET['llama'])) {
echo "Llama's are ok I guess";
} elseif (isset($_GET['monkey'])) {
echo "Yeah, monkeys are cool!";
} elseif (isset($_GET['giraffe'])) {
echo "Giraffe's are a bit wierd";
} else {
echo "Please choose don't choose Whale or Moth. No reason, just choose something else.";
}
}
?>
Code: Select all
<form method=get action="<?php echo $_SERVER['PHP_SELF'] ?>"> <select> <option name=sloth>Sloth</option> <option name=llama>Llama</option> <option name=monkey>Monkey</option> <option name=giraffe>Giraffe</option> <option name=gorilla>Gorilla</option> <option name=whale>Whale</option> <option name=moth>Moth</option> </select> <input type="submit" value="submit" /></form>