You are here: Re: [PHP] shortest possible check: field is set, integer or 0 « PHP « IT news, forums, messages
Re: [PHP] shortest possible check: field is set, integer or 0

Posted by "Richard Lynch" on 11/11/77 11:33

On Wed, November 30, 2005 5:10 pm, Chris Lott wrote:
> What is the shortest possible check to ensure that a field coming from
> a form as a text type input is either a positive integer or 0, but
> that also accepts/converts 1.0 or 5.00 as input?

This might be good enough:

if (isset($_POST['x'])){
if (!preg_match('/([0-9]*)(\\.0*)?/', $_POST['x']){
//invalid
}
else{
$_CLEAN['x'] = (int) $_POST['x'];
}
}

--
Like Music?
http://l-i-e.com/artists.htm

 

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

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