![]() |
![]() |
||||||
|
|||||||
| Tags: correctly, express, would |
![]() |
|
|||
|
How would I express this correctly?
... elseif ($row_rs['loggedinip'] != $_SERVER['REMOTE_ADDR'] AND now("Y-m-d H:i:s") < $row_rs['lastlogin']+120 minutes) { die(header("Location: http://domain.com/login.php")); } else {... |
| Sponsored Links |
|
|||
|
.oO(jsteinmann)
>this part in itself... how do I write this correctly? > >if ($row_rs['loggedinip'] != $_SERVER['REMOTE_ADDR'] AND now("Y-m-d >H:i:s") < $row_rs['lastlogin']+120 minutes) { If it has to be done in PHP, use Unix Timestamps for the calculation. Turn the date in $row_rs['lastlogin'] into such a timestamp with strtotime(). The current timestamp can be obtained with time(). Doing the math should be quite simple then. Micha |
|
|||
|
.oO(jsteinmann)
>Its not on a unix system Doesn't matter. Unix timestamps also work on Windows, they are just one way to store a time code withing the range of (roughly) 1902-2038. >mysql data is in a datetime format You could also let MySQL already return the date as a Unix timestamp or even do the entire calculation in MySQL, as already suggested. You could let MySQL return both: the normal 'lastlogin' field and another one with 'lastlogin'+120 minutes or whatever. Or do the entire date test in SQL and just return a boolean value if the last login was more than 120 minutes ago or not ... there are several different ways. Micha |
|
|||
|
i'm trying to read between the lines and I understand your theory, but I'm not
having much luck with implementing it. for example: elseif ($row_rs['loggedinip'] != $_SERVER['REMOTE_ADDR'] AND time() < date('Y-m-d',strtotime($row_rs['lastlogin']+120 minutes) { this doesn't work. The datetime is stored in the database as Y-m-d H:i:s |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
- Contact Us
-|-
Adobe Dreamweaver Forums -|-
Archive -|-
Top -|-Rules/Disclaimer-|-Help/Support-|-Advertise