Adobe Dreamweaver Forums



Last 10 THreads :         need assistance with buttons pulling in different MC's (Last Post : DPSwebmaster - Replies : 2 - Views : 3 )           »          input text question (Last Post : redsox05 - Replies : 2 - Views : 3 )           »          The formal parameter "@CCNumber" was not declared as anOUTPUT parameter (Last Post : athanasiusrc - Replies : 1 - Views : 2 )           »          Going from ASP TO PHP (Last Post : David Powers - Replies : 9 - Views : 10 )           »          Div or iFrame resize depending on content. (Last Post : Nancy O - Replies : 1 - Views : 2 )           »          can someone recommend a good hosting co. (Last Post : P@tty Ayers ~ACE - Replies : 22 - Views : 23 )           »          Favicon (Dreamweaver MX 2004) (Last Post : Nancy O - Replies : 2 - Views : 3 )           »          Simple Template Help (Last Post : JJS IN AK - Replies : 5 - Views : 9 )           »          Need help! Browser Issues with CSS - Problems with IE (Last Post : Nancy O - Replies : 6 - Views : 9 )           »          Dreamweaver Extentions (Last Post : Twocans - Replies : 4 - Views : 5 )           »         


Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
User Info Statistics
Go Back   Adobe Dreamweaver Forums > Dreamweaver: Main > Dreamweaver General
 
Tags: , ,



Reply
  #1 (permalink)  
Old 05-03-2008, 03:59 PM
jsteinmann
 
Posts: n/a
Diggs:
Default How would I express this correctly

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 {...



Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-03-2008, 03:59 PM
SnakEyez02
 
Posts: n/a
Diggs:
Default Re: How would I express this correctly

You should not need the die command if you are redirecting someone at that point if the script fails.
Reply With Quote
  #3 (permalink)  
Old 05-03-2008, 03:59 PM
jsteinmann
 
Posts: n/a
Diggs:
Default Re: How would I express this correctly

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) {

Reply With Quote


  #4 (permalink)  
Old 05-03-2008, 03:59 PM
Michael Fesser
 
Posts: n/a
Diggs:
Default Re: How would I express this correctly

.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
Reply With Quote
  #5 (permalink)  
Old 05-03-2008, 03:59 PM
jsteinmann
 
Posts: n/a
Diggs:
Default Re: How would I express this correctly

Its not on a unix system
mysql data is in a datetime format



Reply With Quote
  #6 (permalink)  
Old 05-03-2008, 03:59 PM
Michael Fesser
 
Posts: n/a
Diggs:
Default Re: How would I express this correctly

.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
Reply With Quote


  #7 (permalink)  
Old 05-03-2008, 03:59 PM
jsteinmann
 
Posts: n/a
Diggs:
Default Re: How would I express this correctly

i understand the theory, but id appreciate a snippet of code
Reply With Quote
  #8 (permalink)  
Old 05-03-2008, 03:59 PM
jsteinmann
 
Posts: n/a
Diggs:
Default Re: How would I express this correctly

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

Reply With Quote
  #9 (permalink)  
Old 05-03-2008, 03:59 PM
jsteinmann
 
Posts: n/a
Diggs:
Default Re: How would I express this correctly

is this right?

elseif ($row_rs['loggedinip'] != $_SERVER['REMOTE_ADDR'] && getdate() < (strtotime($row_rs['lastlogin']+120))) {

Reply With Quote


  #10 (permalink)  
Old 05-03-2008, 03:59 PM
jsteinmann
 
Posts: n/a
Diggs:
Default Re: How would I express this correctly

elseif ($row_rs['loggedinip'] != '204.9.76.12' && date('Y-m-d H:i:s', strtotime('now')) < date('Y-m-d H:i:s', strtotime("+2 minutes", strtotime($row_rs['lastlogin'])))) {
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 11:52 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Inactive Reminders By Mished.co.uk