Solved

Js and coldfusion.

Posted on 2002-06-05
9
127 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 19

Expert Comment

by:cheekycj
Comment Utility
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

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

Accepted Solution

by:
cheekycj earned 100 total points
Comment Utility
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
Comment Utility
cj I'm haven't tested it jet.  just a lil O.B.E(s).will let you know.
0
 

Author Comment

by:jriver12
Comment Utility
thanks again
0
 
LVL 19

Expert Comment

by:cheekycj
Comment Utility
Glad I could help and Thanx for the "A".

CJ
0

Featured Post

Superior storage. Superior surveillance.

WD Purple drives are built for 24/7, always-on, high-definition security systems. With support for up to 8 hard drives and 32 cameras, WD Purple drives are optimized for surveillance.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
website file permissions 4 54
Service "nameserver" appears to be down 4 475
WSUS Client Issues 52 955
IIS Site Configuration Copy 2 67
Introduction In this tutorial, I'll explain how to create an animated progress meter in a wireframe prototype developed using Axure RP 7.0 - a leading prototyping tool for designing web sites and software. (For more information about Axure and gett…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
The purpose of this video is to demonstrate how to integrate Mailchimp with Facebook. This will be demonstrated using a Windows 8 PC. Mailchimp and Facebook will be used. Log into your Mailchimp account. : Click on your name. Go to Account Setti…
The purpose of this video is to demonstrate how to integrate Mailchimp with WordPress, by placing a Mailchimp signup form on a WordPress Page or Post. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mailchi…

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now