Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #7321

Re: Verifying time in php

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!feeder.erje.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From "J.O. Aho" <user@example.net>
Newsgroups comp.lang.php
Subject Re: Verifying time in php
Date Sun, 14 Oct 2012 20:41:36 +0200
Lines 37
Message-ID <ae0fb0F206uU1@mid.individual.net> (permalink)
References <slrnk7l2e1.3f9.houghi@penne.houghi> <slrnk7l52o.3f9.houghi@penne.houghi> <advrhmFroasU1@mid.individual.net> <slrnk7llq2.3f9.houghi@penne.houghi> <slrnk7lt3n.3f9.houghi@penne.houghi>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
X-Trace individual.net 4fVOSDN3YZdskijFQn7HngOQYMr+WvmqVE3QWtFWUi1cs+Vl2uCIZDiwx+C8ZiVbKQ
Cancel-Lock sha1:mhFG5fgdmtqkZC44MdD8QmQZP6k=
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120923 Thunderbird/15.0.1
In-Reply-To <slrnk7lt3n.3f9.houghi@penne.houghi>
Xref csiph.com comp.lang.php:7321

Show key headers only | View raw


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

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Verifying time in php houghi <houghi@houghi.org.invalid> - 2012-10-14 11:45 +0200
  Re: Verifying time in php Denis McMahon <denismfmcmahon@gmail.com> - 2012-10-14 10:25 +0000
    Re: Verifying time in php houghi <houghi@houghi.org.invalid> - 2012-10-14 13:50 +0200
      Re: Verifying time in php Denis McMahon <denismfmcmahon@gmail.com> - 2012-10-14 21:12 +0000
  Re: Verifying time in php houghi <houghi@houghi.org.invalid> - 2012-10-14 12:30 +0200
    Re: Verifying time in php "J.O. Aho" <user@example.net> - 2012-10-14 15:03 +0200
      Re: Verifying time in php houghi <houghi@houghi.org.invalid> - 2012-10-14 17:16 +0200
        Re: Verifying time in php Michael Fesser <netizen@gmx.de> - 2012-10-14 17:50 +0200
          Re: Verifying time in php "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2012-10-14 18:22 +0200
          Re: Verifying time in php "Peter H. Coffin" <hellsop@ninehells.com> - 2012-10-14 11:41 -0500
            Re: Verifying time in php Martin Leese <please@see.Web.for.e-mail.INVALID> - 2012-10-14 11:06 -0600
              Re: Verifying time in php houghi <houghi@houghi.org.invalid> - 2012-10-14 19:41 +0200
            Re: Verifying time in php Michael Fesser <netizen@gmx.de> - 2012-10-14 21:03 +0200
              Re: Verifying time in php houghi <houghi@houghi.org.invalid> - 2012-10-14 22:39 +0200
        Re: Verifying time in php Christoph Becker <cmbecker69@gmx.de> - 2012-10-14 17:52 +0200
        Re: Verifying time in php houghi <houghi@houghi.org.invalid> - 2012-10-14 19:20 +0200
          Re: Verifying time in php "J.O. Aho" <user@example.net> - 2012-10-14 20:41 +0200
          Re: Verifying time in php Christoph Becker <cmbecker69@gmx.de> - 2012-10-14 20:49 +0200
            Re: Verifying time in php houghi <houghi@houghi.org.invalid> - 2012-10-14 22:32 +0200
  Re: Verifying time in php Richard Damon <news.x.richarddamon@xoxy.net> - 2012-10-14 11:44 -0400
  Re: Verifying time in php Luuk <luuk@invalid.lan> - 2012-10-14 21:28 +0200

csiph-web