Solved

Js and coldfusion.

Posted on 2002-06-05
9
129 Views
Last Modified: 2013-12-24
I am attempting something that I hate to work with, that is dates.

could someone help me out or point me in the right direction.

this is what I am trying to accomplish.

I am trying to script out a code that will run in my include.cfm.
My include.cfm checks for the existance of a login.

I would like it to check to see if today is =<5 days before my  needtochange(field in table of db) date.
if it is I would like the user to have to go to my pwdchange.cfm and change there password before proceeding.
if the date (today)does not fall in that criteria then proceed as normal thru the site.

thanks in advance
 
0
Comment
Question by:jriver12
  • 4
  • 4
9 Comments
 
LVL 5

Expert Comment

by:Yog
ID: 7059253
since you are checking for login after submitting in the server side,it is better you script this with coldfusion, or create a stored proc which does this, and return a boolean yes or no, are you using sqlserver ?
0
 

Author Comment

by:jriver12
ID: 7059271
yes I am using sql server 2000.
can you help point me in the right direction I have not done any of the suggestions you have mentioned.?
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 7059313
your DB is MSAccess right?

Try this:

<cfquery name="myquery" datasource="mydatasource">
    SELECT needtochange FROM user_account_table
    where accountID = #SESSION.accountID#
</cfquery>

<cfset daysUntilPasswordChangeRequired = DateDiff("d", Now(), myquery.needtochange)>

<cfif daysUntilPasswordChangeRequired <= 5>
   <cflocation url="pwdchange.cfm">
</cfif>

CJ
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 19

Expert Comment

by:cheekycj
ID: 7059325
That should work with SQL Server too.

I am sure you can incorperate the check in the query itself.

When you check login, you can check for it and redirect immediately.  Is needtochange always in the future (or ideally is it)?

0
 

Author Comment

by:jriver12
ID: 7059332
cj,
yes needtochange is always in the future.
0
 
LVL 19

Accepted Solution

by:
cheekycj earned 100 total points
ID: 7059378
you can try this:
<cfquery name="checkLogin" datasource="mydatasource">
   SELECT DATEDIFF (d, sysdate, needtochange) as daysUntilPasswordChangeRequired, accountID FROM user_account_table
   where username = '#Form.userName#' And Password = '#FORM.password#'
   
</cfquery>


<cfif checkLogin.daysUntilPasswordChangeRequired <= 5>
  <cflocation url="pwdchange.cfm">
</cfif>

OR

<cfquery name="myquery" datasource="mydatasource">
   SELECT DATEDIFF (d, sysdate, needtochange) as daysUntilPasswordChangeRequired FROM user_account_table
   where accountID = #SESSION.accountID#
</cfquery>

<cfif myquery.daysUntilPasswordChangeRequired <= 5>
  <cflocation url="pwdchange.cfm">
</cfif>


HTH,
CJ
0
 

Author Comment

by:jriver12
ID: 7062758
cj I'm haven't tested it jet.  just a lil O.B.E(s).will let you know.
0
 

Author Comment

by:jriver12
ID: 7069704
thanks again
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 7070166
Glad I could help and Thanx for the "A".

CJ
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ip / url redirect 13 73
Setting Up Local Lan Web Server 1 65
http to https 3 70
Two wordpress questions 3 62
Turn A Profile Picture Into A Cartoon Using Photoshop And Illustrator This tutorial will teach you how to make a cartoon style image out of a regular picture. I have tried to keep the tutorial as simple as possible. I used Adobe CS4 for this tuto…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
The purpose of this video is to demonstrate how to create a Printer Friendly PDF on a WordPress Page. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome Screenshot” Google Chrome Extension, and SmallPDF.com Log…
The purpose of this video is to demonstrate how to automatically show related posts at the bottom of a blog post in WordPress. This will be demonstrated using a Windows 8 PC. Plugin “Yet Another Related Posts Plugin” will be used. Go to your…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question