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 #179389 is a reply to message #179387] Sun, 14 October 2012 18:41 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 19:20, houghi wrote:

> Found finaly the solution. Instead of looking at the seperate values and
> then trying to combine them, it is better to combine them and then
> evaluate them with
> $testtime=$_POST['hours'].$_POST['minutes'].$_POST['seconds'];
>
> $hours $min $sec $testtime Valid?
> - - - - No
> 1 - - 1 Yes
> 1 - 1 11 Yes
> - 1 - 1 Yes
> 1 1 1 111 Yes
> A - - A No
> 1 A - 1A No
> 1A - - 1A No
>
> That way I can just do a 'is_numeric($testtime)' and no need to use
> is_set or anything else.

an alternative is:

if you have <input name="variable[xxx]" ...> in your form

then you can in your script
$ok = true;
foreach($_POST['variable'] as $value) {
if(!is_numeric($value))
$ok = false;
}

even if your method works now, I wouldn't bet on it in the future.

--

//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: Sat Nov 23 19:25:59 GMT 2024

Total time taken to generate the page: 0.04693 seconds