RE: [PHP] RE: yes and no buttons and posting

From: Date: Thu, 09 May 2002 03:10:15 +0000
Subject: RE: [PHP] RE: yes and no buttons and posting
Groups: php.general 
Request: Send a blank email to php-general+get-96750@lists.php.net to get a copy of this message
how about use <argh> include, so: <? switch($_POST['choice']) { case "yes" : include "test2.php"; break; // exit; might be better here case "no" : include "order1.php"; break; } ?> -----Original Message----- From: baldey_uk [mailto:baldey_uk@SoftHome.net] Sent: Thursday, May 09, 2002 12:53 PM To: Austin Marshall Cc: Php-General Subject: [PHP] RE: yes and no buttons and posting 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; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#96750) next »