Try this instead. I couldn't get Devon's to work on my system either, but
this one does. Note the use of the empty() function which tests a string
for emptiness.
Let me know if it works?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Test Form</title>
</head>
<body>
<?
if (empty($username))
{
echo "
<form method=post action=".$PHP_SELF.">
<input type=\"text\" name=\"username\"><br>
<input type=\"submit\" value=\"Post Data\">
</form><i>No data yet, or username is empty.</i>";
}
else
{
echo "<b>Username:</b> " . $username;
}
?>
</body>
</html>
-----Original Message-----
From: Chris Earle [mailto:[EMAIL PROTECTED]]
Sent: 20 February 2002 02:09
To: [EMAIL PROTECTED]
Subject: [PHP-WIN] Re: WinXP Error Passing Variables (and creating)
No offense taken, but I have never done this before so I don't really know
what I'm doing with the variable passing and stuff (aside from C++ and VB
knowledge). I copied that from the book exactly and it did not work.
Your form does not work either, it simply gives me the else statement's
actions ("No data yet, or $username is empty."). I do believe I hit the bug
they were talking about and am now thinking of getting Linux from my boss
too install and run for PHP. Thanks for the help.
"Devon Knowles" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> No offense, but you are doing something completely wrong. For starters,
> your <form> has neither a method nor an action. Try this code, if you have
> Apache and PHP installed correctly, it will work. Even on XP.
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> <html>
> <head>
> <title>Test Form</title>
> </head>
> <body>
> <form action="<?= $PHP_SELF ?>" method="post">
> <input type="text" name="username"><br>
> <input type="submit" value="Post Data">
> </form>
> <?
> if ($username)
> {
> echo "<b>Username:</b> " . $username;
> } else
> {
> echo "<i>No data yet, or \$username is empty.</i>";
> }
> ?>
> </body>
> </html>
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php