[UPHPU] Newbie needs help
dan.stephenson at gmail.com
Thu Jun 9 16:31:38 MDT 2005
On 6/9/05, John M <johnm_ul at yahoo.com> wrote:
> I'm reading a book that was made in the year 2000 and
> I think that is probably my problem. I'm trying to
> follow along with the examples inside of it but I'm
> How I think this is supposed to work is that an html
> page asks for a name and if nothing is entered and the
> GO/Submit button is pressed, it is supposed to ask for
> the name again. Instead I'm getting a blank page.
> Below is what I have in each file.
> (samplepage.php from the book. Note: I added the
> first line because of the global variable change.)
> $name = $_POST['name'];
> if (!isset($name)):
> <!-- No name has been provided, so we
> prompt the user for one. -->
> <form action="<?=echo($PHP_SELF)?>" method="get">
> Please enter your name: <input type="text"
> name="name" />
> <input type="submit" value="GO" />
> <?php else: ?>
> <p>Your name: <?=$name?></p>
> <p>This paragraph contains a <a
> that passes the name variable on to the next
> <?php endif; ?>
> (the following is in the body of my html file. I
> believe this file works fine because I've used it in a
> previous example which did work.)
> <form action="samplepage.php" method="post">
> name: <input type="text" name ="name" /> <br />
> <input type="submit" value="go" />
> I'm thinking that it's not working because of the
> version differences from where ever php was in 2000 to
> version 5 now...mixed with my "newness" to php. Maybe
> the better question would be, are there better (more
> recent) books available that someone on this list has
> actually read and would recommend?
> Discover Yahoo!
> Have fun online with music videos, cool games, IM and more. Check it out!
> UPHPU mailing list
> UPHPU at uphpu.org
> IRC: #uphpu on irc.freenode.net
It appears that you are retrieving name with $_POST, but your form is
using the GET method...you could just retrieve it with $_REQUEST
(which should cover $_GET, $_POST and $_COOKIE)...
More information about the UPHPU