You are here: Re: Query about empty POST arrays « PHP Programming Language « IT news, forums, messages
Re: Query about empty POST arrays

Posted by Justin Koivisto on 10/06/05 17:36

DrewBe12@gmail.com wrote:

> Exactly.
>
> if ($_POST['submit']) // Gives you the validation that the submit
> button itself has been pushed,
>
> then to detect an empty field
>
> $myfield = trim($myfield);
> if (!$myfield)
> {
> echo "error, no data provided";
> }

Assuming that $myfield was a text input, a hidden field, a select
element, a textarea, etc. Checkboxes that aren't selected and radio
button groups that don't have a value chosen will not even exist in the
$_POST array... Also, you should have used:

$myfield = trim($_POST['myfield']);

Get out of the habit of using register_globals - especially when trying
to give examples in a newsgroup. Too many newbies will wonder why it
isn't working for them, then we'll get the whole "if
register_globals=On" threads again...

--
Justin Koivisto, ZCE - justin@koivi.com
http://koivi.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

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