Sascha Cunz wrote this stuff back on Mon, 14 Oct 2002 00:09:58 +0200:
> register_globals defaults now to off. Use the superglobals instead.
> <?
> if (isset($_GET['name'])) {
> echo "Hallo ".$GET['name'];
> }
> else {
> echo "<FORM action='test.php' method=get>
> <input type=text name=name>
> <input type=submit name=action value=sendit>";
> }
> ?>
> Sascha
The value of name for the submit button is wrong - it should be the same
as the value you gave the isset statement, in this case it should be
<input type="submit" name="name" value="sendit">
Better yet is to use isset($submit) and the value for the submit
statement is also name="submit" -
<input type="submit" name="submit" value="sendit">
of course value is optional. So you end up with this -
<?
if (isset($_GET['submit']))
{
echo "Hallo ".$GET['name'];
}
else
{
echo "<FORM action='test.php' method=get>
<input type='text' name='name'>
<input type='submit' name='submit' value='sendit'>";
}
?>
--
Chip
> Am Sonntag, 13. Oktober 2002 23:40 schrieb Lars H. Korte:
> > Hi,
> > I've updated to PHP 4.2.3 and wrote this simple Script:
> >
> > <?
> > if (isset($name)) {
> > echo "Hallo $name";
> > }
> > else {
> > echo "<FORM action='test.php' method=get>
> > <input type=text name=name>
> > <input type=submit name=action value=sendit>";
> > }
> > ?>
> >
> > I would expect the following:
> > The site starts with the form, then I enter my name (Lars) and click
> > the send-button. Then the script says Hello Lars.
> >
> > The actual output is:
> > The site starts with the form, I enter my name and click the button,
> > then the form keeps being there, no "Hello"-message.
> >
> > Has there changed something in PHP-Coding since I've learned it a
> > few years before?
> >
> > There seems to be a diffrence between clicking the send button and
> > pressing Enter. Has this always been so?
> >
> > regards
> > Lars
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php