Re: PHP_SELF NEW.....?????Continue2
| From: | David Otton | Date: | Tue, 04 Sep 2001 19:41:13 +0000 |
| Subject: | Re: PHP_SELF NEW.....?????Continue2 | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-65876@lists.php.net to get a copy of this message | ||
On Mon, 3 Sep 2001 17:15:25 -0700, you wrote:
>So, with the PHP_self (in my hangman game) I probably can send the value of
>my variable to the same page. now my next question is:
>
>How do i maintain the content of the page which is build based on the value
>passed from the previous submision? Do I confuse you know?
I think this is what you are asking for :
<?
if (isset($page)) {
/* variable page exists, so we are on the second page */
echo "<p>The string entered was : $input</p>";
} else {
/* page does not exist, so we should display the form */
?>
<form method="post" action="<?=$PHP_SELF?>">
<input type="hidden" name="page" value="1">
Input : <input type="text" name="input">
<input type="submit" name="go" value="Go!">
</form>
<?
}
?>
(Caution - I haven't tested this... could be typos)
If you want multiple pages, you can do this:
if (!isset($page)) {
/* do page 1 */
} else {
switch($page) {
case '1' :
/* do page 2 */
break;
case '2' :
/* do page 3 */
break;
default :
/* someone's messing with the URL string */
break;
}
}