Re: yes and no buttons and posting

From: Date: Thu, 09 May 2002 03:07:32 +0000
Subject: Re: yes and no buttons and posting
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-96749@lists.php.net to get a copy of this message
That code, won't or shouldn't work. You can not out put anything before the header() function. You can fix that by moving that part of the code to the very beginning. Also, you can use header("Location: ..."); with relative URLs without any extra effort on your part... header("Location: index.php"); will work. Baldey_uk wrote:
Hello again, i am trying to do as said below but have a problem. Is there anyway to say 'go to this page in PHP' without using headers as i would like to use relative URL's and not abolsute ones. Also is this fine that the code here is all on the same page or do i have to have the form posting to a php page and then do the swtich case from there? <body> <form method="post"> <input type="submit" name="choice" value="Yes" width="3" height="3"> <input type="submit" name="choice" value="no" width="3" height="3"> <? switch($_POST['choice']) { case "yes" : do header("Location: http://".$_SERVER['HTTP_HOST']
                      .dirname($_SERVER['PHP_SELF'])
                      ."/".test2.php); break; # < - i dont want to have to
use this case "no" : do header("Location: order1.php") else; break; }?> </form> </body> Once again thanks for helping out a PHP newbie. baldey_uk -----Original Message----- From: Austin Marshall [mailto:amars@pdq.net] Sent: 09 May 2002 03:06 To: Baldey_uk Cc: Php-General Subject: Re: yes and no buttons and posting Baldey_uk wrote:
Hi all again, This is probably another simple question to answer: I want to have a page where someone answers a question with a yes or no button, which are provided by HTML (im not sure whether it is possible to
do
this with PHP?). How with php can i say ' if they hit the HTML yes button, go to this page else if they hit the HTML no button go to this page'?
Thanks
again for any help! Cheers From baldey_uk
Quite easily... have two buttons, <input type=submit name=choice value=yes><input type=submit name=choice value=no> and in your script have: switch($_GET['choice']) // or $_POST['choice'] accordingly { case "yes" : do this; break; case "no" : do something else; break; }


« previous php.general (#96749) next »