FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Verifying time in php
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Verifying time in php [message #179379 is a reply to message #179377] Sun, 14 October 2012 13:03 Go to previous messageGo to previous message
J.O. Aho is currently offline  J.O. Aho
Messages: 194
Registered: September 2010
Karma:
Senior Member
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
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Curl chmod file transfer problem...
Next Topic: test
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 24 12:24:30 GMT 2024

Total time taken to generate the page: 0.04522 seconds