From: Rob Kapfer [mailto:[EMAIL PROTECTED] 

> Hello, This is a new install of PHP 5.0.4 on XP, I'm testing if it's
> installed correctly with the usual test.htm:
> <form action="action.php" method="POST">
> 
> Your name: <input type="text" name="name" />
> 
> Your age: <input type="text" name="age" />
> 
> <input type="submit">
> 
> </form>
> 
> Action.php:
> 
> <?php
> 
> echo $_POST['name'];
> 
> echo $_POST['age'];
> 
> ?>
> 
> Results:
> 
> C:\NCC>action.php
> 
> Notice: Undefined index: name in C:\NCC\action.php on line 2
> 
> Notice: Undefined index: age in C:\NCC\action.php on line 3
> 
> C:\NCC>

That's correct behavior. As you're simply running action.php on its own,
it sees that $_POST['name'] and $_POST['age'] don't exist and outputs a
notice for each.

To avoid the notices, ensure that those keys exist before calling
something like echo on them:

<?php

if (!empty($_POST['name'])) {
        echo $_POST['name'];
} else {
        echo 'Name not set';
}

if (!empty($_POST['age'])) {
        echo $_POST['age'];
} else {
        echo 'Age not set';
}

?>

HTH!


-- 
Mike Johnson             Smarter Living, Inc.
Web Developer            www.smartertravel.com
[EMAIL PROTECTED]   (617) 886-5539

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to