Re: Checking Post Data against DB Data
| From: | kvigor | Date: | Tue, 17 Jul 2007 14:23:36 +0000 |
| Subject: | Re: Checking Post Data against DB Data | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-259016@lists.php.net to get a copy of this message | ||
I really like the re-coding it's great. I'm still new and below code is
definitely more efficient.
FYI: I do have date field sorry I wasn't so clear. I just didn't post all
code.
""Richard Lynch"" <ceo@l-i-e.com> wrote in message
news:1707.24.1.37.132.1184193310.squirrel@www.l-i-e.com...
> Doing a select to get every record, and then looping through them all,
> concatenating a bunch of stuff together, and then using PHP to test ==
> is not very efficient...
>
> Why not just:
>
> $sql = array_map('mysql_real_insert_string', $POST);
> $query = " select count(*) from central ";
> $query .= " where conName = $sql[conName] ";
> $query .= " and conAddress = $sql[conAddress] ";
> .
> .
> .
> $query .= " and SOME_DATETIME_FIELD_WHEN_THEY_REGISTERED >=
> date_sub(now(), interval 1 day) ";
>
> Also note that your are currently comparing the $_POST['timeStamp']
> which is *probably* generated at the time the HTML form was sent with
> time(); which is when the script is processing, which will be MUCH
> less than one day, unless a user opens up the form, walks away for 24
> hours, and then comes back to complete registration...
>
> You need a field in the database from previous registration to compare
> to time().