Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.musoftware.de!wum.musoftware.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "J.O. Aho" Newsgroups: comp.lang.php Subject: Re: Verifying time in php Date: Sun, 14 Oct 2012 15:03:50 +0200 Lines: 36 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net vuHfn/K1qpvUjspRH9Xy8QMvBiwOA0n0Gl83cf/WFlcChXXnxf+jeQ8Ji64o9uZNQN Cancel-Lock: sha1:UHaZAkeSsuthTkG2EM3lCM/hwjs= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120923 Thunderbird/15.0.1 In-Reply-To: Xref: csiph.com comp.lang.php:7311 On 14/10/12 12:30, houghi wrote: > houghi wrote: >> I have a form that has the following entry fields: >> hours >> minutes >> seconds > > The code can be seen here : http://houghi.org/gopro.php?code > > $realtime=$_POST['hours']*3600+$_POST['minutes']*60+$_POST['seconds']; > > What I want to know if the $realtime is something I could get an error > message form. You would in most cases have a value of some sort, but you can't always relay on that it will for ever be like that (we know PHP makes some big changes from time to time) and what happens further down if you have negative values or huge values. Validate what you get and make a sanity check on what you got before you calculate the realtime value. > I just want to figure out how I can check if Hours, Minutes and Seconds > input is valid. There are quite many is_* functions, among those you have is_numeric()[1] and another one is isset()[2] which gives you true or false. [1]: http://www.php.net/manual/en/function.is-numeric.php [2]: http://www.php.net/manual/en/function.isset.php -- //Aho