RE: yes and no buttons and posting
| From: | baldey_uk | Date: | Thu, 09 May 2002 02:53:10 +0000 |
| Subject: | RE: yes and no buttons and posting | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-96746@lists.php.net to get a copy of this message | ||
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;
}