Click to See Complete Forum and Search --> : switch function not working


keko2005
09-06-2005, 06:30 PM
im am testing a switch function, but it doesnt seem to work. i tried using get and post, and neither seemed to work. i thought i was using it correctly, can someone help me out?

this is wha im using

tester.php
<html>

<head>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<meta name="generator" content="Adobe GoLive">
<title>agl:pagetitle</title>
</head>

<body bgcolor="#ffffff">y
<p><a href="caser.php?post=t1">Get Rock</a></p>
</body>

</html>

caser.php

<?php
switch($HTTP_POST_VARS['post']){
case 't1':
echo "1";

break;
case 't2':
echo "2";

break;
default:
echo "bad";
break;
}

?>



any help or advice would help me out a lot. thanks for your time

NogDog
09-06-2005, 06:41 PM
$post = ''; # initialize it
if(isset($_POST['post'])) # see if it was sent via POST
{
$post = $_POST['post'];
}
elseif(isset($_GET['post'])) # see if it was sent via GET
{
$post = $_GET['post'];
}
if(!empty($post)) # we got it
{
switch($post)
{
case "t1":
echo "1";
break;
case "t2":
echo "2";
break;
default:
echo "bad";
}
}
else
{
echo "uh-oh, didn't get anything";
}