You are here: Re: [PHP] Notice: Undefined index « PHP « IT news, forums, messages
Re: [PHP] Notice: Undefined index

Posted by John Nichel on 04/28/05 22:09

Rob Kapfer wrote:
> 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>
>

Did you give any value to name and age in your form?

Check to see if a variable exists before trying to do something with it...

if ( isset ( $_POST['name'] ) ) {
echo ( $_POST['name'] );
}

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
john@kegworks.com

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация