PHP help with Control Structure

Hi,
I'm learning PHP, using PHP 5.2.x and can't figure out
what I am doing wrong with this simple control structure,
an if-else block. It's an example from a text and it seems
pretty simple but I get nothing on the page. The
form never appears and it should the first time the page is
called. It's an example of a multipurpose page where
the first time it is called, the script uses the form to
request the users name. Each time later the page is
called, the form won't need to be called because the
variable is later assigned a value. Here it is, please help...
see just below...
Bruce

<body>
<?php if (isset($_GET['name']) ): ?>
<p>Your name: <?php echo($_GET['name']); ?></p>
<p>This paragraph contains a
<a href="newpage.php?name=<?php echo(urlencode($_GET['name'])); ?>">
link</a> that passes the
name variable on to the next document.</p>
} else {
/* No name has been provided, so we
prompt the user for one. */
<form action=<?php echo($PHP_SELF)); ?> METHOD=GET>
Please enter your name: <INPUT TYPE=TEXT NAME="name">
<INPUT TYPE=SUBMIT VALUE="GO" >
</form>
<?php endif; ?>
</body>
Bruce Whealton [ Di, 06 Februar 2007 01:17 ] [ ID #1619397 ]

Re: PHP help with Control Structure

Message-ID: <45c7c91f$0$5753$4c368faf [at] roadrunner.com> from Bruce
Whealton contained the following:

> I'm learning PHP, using PHP 5.2.x and can't figure out
>what I am doing wrong with this simple control structure,
>an if-else block. It's an example from a text and it seems
>pretty simple but I get nothing on the page.

Get a new book. The following works


<body>
<?php if (isset($_GET['name']) ){ ?>
<p>Your name: <?php echo($_GET['name']); ?></p>
<p>This paragraph contains a
<a href="<?php echo $_SERVER['PHP_SELF']; ?>?name=<?php
echo(urlencode($_GET['name'])); ?>">
link</a> that passes the
name variable on to the next document.</p>
<?php
} else {
/* No name has been provided, so we
prompt the user for one. */
?>
<form action=<?php echo $_SERVER['PHP_SELF']; ?> METHOD="GET">
Please enter your name: <INPUT TYPE="TEXT" NAME="name">
<INPUT TYPE="SUBMIT" VALUE="GO" >
</form>
<?php } ?>
</body>

--
Geoff Berrow 0110001001101100010000000110
001101101011011001000110111101100111001011
100110001101101111001011100111010101101011
Geoff Berrow [ Di, 06 Februar 2007 02:18 ] [ ID #1620651 ]
PHP » alt.php » PHP help with Control Structure

Vorheriges Thema: download files from a website
Nächstes Thema: PHP Study Groups online/beginners groups