jriver12
asked on
Two Part Question Probably Real Easy.
this is my question.
I have a log in script that ends the session at 25 min of inactivity within the application. at that time if the user attemps to do something they get a page that tells them to login at that time once they restablish the identity then I would like them to be able to return to the page that they had requested with out loosing any information or having to renavigate thru the application.
secondly.
I need to create a page that displays the result set of the query in colums. ie.
my header
recid name recid name
1 a 4 d
2 b 5 e
3 c 6 f
the amount of records returned could be up to 1300.
I would like to have a page count like page 1 of ?? at the bottom of the page.
how feasable is this.
I thank you in advance....:)
I have a log in script that ends the session at 25 min of inactivity within the application. at that time if the user attemps to do something they get a page that tells them to login at that time once they restablish the identity then I would like them to be able to return to the page that they had requested with out loosing any information or having to renavigate thru the application.
secondly.
I need to create a page that displays the result set of the query in colums. ie.
my header
recid name recid name
1 a 4 d
2 b 5 e
3 c 6 f
the amount of records returned could be up to 1300.
I would like to have a page count like page 1 of ?? at the bottom of the page.
how feasable is this.
I thank you in advance....:)
ASKER
cheekycj
I think I misspoke,
I am not looking for pagination.
what I am trying to achive is the following
I would like to have a table that would have a header
and then have 4 columns.
my header
recid name recid name
1 a 4 d
2 b 5 e
3 c 6 f
I would like for all the records returned be shown in the browser,
however after every 42-50 recordI would like the header to apear as if it was a nother table holding the information.
my intent is to print from the browser and force individual pages after the count has reached 42-??(undecided)
<style media="print">
BR.pageBreak { page-break-after: always }
</style>
i will try to post something to give you a better Idea in a lil.
I think I misspoke,
I am not looking for pagination.
what I am trying to achive is the following
I would like to have a table that would have a header
and then have 4 columns.
my header
recid name recid name
1 a 4 d
2 b 5 e
3 c 6 f
I would like for all the records returned be shown in the browser,
however after every 42-50 recordI would like the header to apear as if it was a nother table holding the information.
my intent is to print from the browser and force individual pages after the count has reached 42-??(undecided)
<style media="print">
BR.pageBreak { page-break-after: always }
</style>
i will try to post something to give you a better Idea in a lil.
try this:
<cfset numberOfRecordsBeforeHeade rDisplay = 50>
<cfoutput query="yourQuery">
<!--- Display header --->
<cfif yourQuery.currentRow mod numberOfRecordsBeforeHeade rDisplay EQ 1>
<table>
<tr><td>... header html </td></tr>
</cfif>
<!--- table cell display --->
display your data here.
<!--- Display close table --->
<cfif yourQuery.currentRow mod numberOfRecordsBeforeHeade rDisplay EQ 0 OR yourQuery.currentRow EQ yourQuery.recordCount>
</table>
</cfif>
</cfoutput>
<cfset numberOfRecordsBeforeHeade
<cfoutput query="yourQuery">
<!--- Display header --->
<cfif yourQuery.currentRow mod numberOfRecordsBeforeHeade
<table>
<tr><td>... header html </td></tr>
</cfif>
<!--- table cell display --->
display your data here.
<!--- Display close table --->
<cfif yourQuery.currentRow mod numberOfRecordsBeforeHeade
</table>
</cfif>
</cfoutput>
ASKER
CJ your code worked great with the exception that it does not wrap.
i mean,
when the page hits the recordcount desired in that column
I would like it to populate a nother column with the next recordcount
kind of like a newspaper column that once it reaches its limit it wraps to another colum
i mean,
when the page hits the recordcount desired in that column
I would like it to populate a nother column with the next recordcount
kind of like a newspaper column that once it reaches its limit it wraps to another colum
you want it to wrap column wise too..
ok..
<cfset numberOfRecordsBeforeHeade rDisplay = 50>
<!-- start newspaper table -->
<table>
<tr>
<cfoutput query="yourQuery">
<!--- Display header --->
<cfif yourQuery.currentRow mod numberOfRecordsBeforeHeade rDisplay EQ 1>
<td>
<table>
<tr><td>... header html </td></tr>
</cfif>
<!--- table cell display --->
display your data here.
<!--- Display close table --->
<cfif yourQuery.currentRow mod numberOfRecordsBeforeHeade rDisplay EQ 0 OR yourQuery.currentRow EQ
yourQuery.recordCount>
</table>
</td>
</cfif>
</cfoutput>
<!-- end newspaper table -->
</tr></table>
ok..
<cfset numberOfRecordsBeforeHeade
<!-- start newspaper table -->
<table>
<tr>
<cfoutput query="yourQuery">
<!--- Display header --->
<cfif yourQuery.currentRow mod numberOfRecordsBeforeHeade
<td>
<table>
<tr><td>... header html </td></tr>
</cfif>
<!--- table cell display --->
display your data here.
<!--- Display close table --->
<cfif yourQuery.currentRow mod numberOfRecordsBeforeHeade
yourQuery.recordCount>
</table>
</td>
</cfif>
</cfoutput>
<!-- end newspaper table -->
</tr></table>
ASKER
CJ,
this is what I have but it is still not wrapping the original 2 colums to another 2 colums. for a total of 4 colums (5 if you include the spacer.
what it is doing is just continuosly doing the newspaperwrap indefinately.
I am just not understanding how to make it go from 2 columns of data
each 1 record will fill 2 colums name and number
if the recordcount for that column is exceeded then make another 2 colums and populate them until filled.
<cfset numberOfRecordsBeforeHeade rDisplay = 38>
<!-- start newspaper table -->
<table width="725" height="100%">
<tr>
<cfoutput query="alphalist">
<!--- Display header --->
<cfif alphalist.currentRow mod numberOfRecordsBeforeHeade rDisplay EQ 1>
<td>
<table width="693">
<tr valign="top" align="center">
<td colspan="4"><font size="+2">Alpha list by Companies</font> </td>
</tr>
<td></cfif>
<!--- table cell display --->
<tr>
<td width="45%">#co_name#</td>
<td width="5%">#conumber#</td>
</tr>
<!--- Display close table --->
<td width="25%"><cfif alphalist.currentRow mod numberOfRecordsBeforeHeade rDisplay EQ 0 OR alphalist.currentRow EQ
alphalist.recordCount>
</table>
</td>
</cfif>
</cfoutput>
<!-- end newspaper table -->
</tr></table>
this is what I have but it is still not wrapping the original 2 colums to another 2 colums. for a total of 4 colums (5 if you include the spacer.
what it is doing is just continuosly doing the newspaperwrap indefinately.
I am just not understanding how to make it go from 2 columns of data
each 1 record will fill 2 colums name and number
if the recordcount for that column is exceeded then make another 2 colums and populate them until filled.
<cfset numberOfRecordsBeforeHeade
<!-- start newspaper table -->
<table width="725" height="100%">
<tr>
<cfoutput query="alphalist">
<!--- Display header --->
<cfif alphalist.currentRow mod numberOfRecordsBeforeHeade
<td>
<table width="693">
<tr valign="top" align="center">
<td colspan="4"><font size="+2">Alpha list by Companies</font> </td>
</tr>
<td></cfif>
<!--- table cell display --->
<tr>
<td width="45%">#co_name#</td>
<td width="5%">#conumber#</td>
</tr>
<!--- Display close table --->
<td width="25%"><cfif alphalist.currentRow mod numberOfRecordsBeforeHeade
alphalist.recordCount>
</table>
</td>
</cfif>
</cfoutput>
<!-- end newspaper table -->
</tr></table>
so you want the newspaper to have a two column effect..
and then keep going down in rows?
and then keep going down in rows?
ASKER
actualy 4 colums
example:
if numberOfRecordsBeforeHeade rDisplay = 3
my header
recid name recid name
1 a 4 d
2 b 5 e
3 c 6 f
if numberOfRecordsBeforeHeade rDisplay <=3
my header
recid name
1 a
2 b
3 c
example:
if numberOfRecordsBeforeHeade
my header
recid name recid name
1 a 4 d
2 b 5 e
3 c 6 f
if numberOfRecordsBeforeHeade
my header
recid name
1 a
2 b
3 c
I don't follow.. give me example using
10 records
12 records
15 records
Thanx,
CJ
10 records
12 records
15 records
Thanx,
CJ
ASKER
I know now by testing that an cfm page in the browser will print 39 records + 1-2 line header total lines per browser page = 40 to 41lines per page(font size depending)
so if lets say my query returns 42 records, the page should look something like
my header
recid name
1 a
2 b
3 c
. .
. .
42 aa
now if it returns lets say 84 then the page should now have 4 colums 1 header and 84 records onthe page.
my header
recid name recid name
1 a 43 ab
2 b 44 ac
3 c 45 ad
. . . .
. . . .
42 aa 84 bb
I hope this clarified it some more.
so if lets say my query returns 42 records, the page should look something like
my header
recid name
1 a
2 b
3 c
. .
. .
42 aa
now if it returns lets say 84 then the page should now have 4 colums 1 header and 84 records onthe page.
my header
recid name recid name
1 a 43 ab
2 b 44 ac
3 c 45 ad
. . . .
. . . .
42 aa 84 bb
I hope this clarified it some more.
ASKER
cj, if your still interested in helping a lost soul.
this is what I have been able to come up with but I still need some help.
this is what is going wrong
it is not starting a new page after lets say 42 recordsin each colum it is just continuing to flow.
again it should break at about 42 records and start a new page.
heres what I have got>
<style media="print">
BR.pageBreak { page-break-after: always }
</style>
</head>
<cfset totrec = #fprdue.RecordCount#>
<!--- number of exhibitornumber - (used for maxrows) --->
<cfset totrubr = #fprdue.RecordCount#>
<!--- column 1: startrow is always 1, maxrows is number of exhibitornumber / 2 --->
<cfset rmax1 = int(#totrubr# / 2)>
<!--- created one table with two columns, in each column one table with a cfouput query with it's own startrow and maxrows --->
</p>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" align="center"><font size="6" face="Arial, Helvetica, sans-serif">this
is my page header</font></td>
</tr>
</table>
<TABLE WIDTH="695" BORDER="0">
<TR>
<tr>
</tr>
<TD VALIGN="top">
<TABLE WIDTH="195" BORDER="0" CELLSPACING="0" CELLPADDING="3">
<TR> <CFOUTPUT QUERY="fprdue" GROUP="exhibitornumber" STARTROW="1" MAXROWS=#rmax1#>
<TD WIDTH="195" ALIGN="center"> </TD>
</TR>
<cfoutput>
<TR>
<TD>#EX_Co_name# </TD>
<td>#Exhibitornumber#</td>
</TR>
<!--- determine last record shown in this column --->
<cfset count1 = #currentrow#>
</CFOUTPUT> </CFOUTPUT>
</TABLE>
<!--- column 2 --->
</TD>
<TD VALIGN="top">
<TABLE WIDTH="195" BORDER="0" CELLSPACING="0" CELLPADDING="3">
<TR>
<!--- <cfoutput>#count1# </CFOUTPUT> --->
<!--- column 2: startrow is last record of column 1 (=count1) +- 1 --->
<cfset srow2 = #count1# +- 1><cfoutput query="fprdue" GROUP="exhibitornumber" STARTROW=#srow2# MAXROWS=#rmax1#>
<TD WIDTH="195" ALIGN="center"> </TD>
</TR>
<cfoutput>
<TR>
<TD>
<!--- #currentrow# --->
#Ex_CO_name# </TD>
<td>#Exhibitornumber#</td>
</TR>
<!--- determine last record shown in this column --->
<cfset count2 = #currentrow#>
</CFOUTPUT> </CFOUTPUT>
</TABLE>
</TABLE>
</TD>
</TR>
</TABLE>
<br class="pageBreak">
</body>
</html>
this is what I have been able to come up with but I still need some help.
this is what is going wrong
it is not starting a new page after lets say 42 recordsin each colum it is just continuing to flow.
again it should break at about 42 records and start a new page.
heres what I have got>
<style media="print">
BR.pageBreak { page-break-after: always }
</style>
</head>
<cfset totrec = #fprdue.RecordCount#>
<!--- number of exhibitornumber - (used for maxrows) --->
<cfset totrubr = #fprdue.RecordCount#>
<!--- column 1: startrow is always 1, maxrows is number of exhibitornumber / 2 --->
<cfset rmax1 = int(#totrubr# / 2)>
<!--- created one table with two columns, in each column one table with a cfouput query with it's own startrow and maxrows --->
</p>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" align="center"><font size="6" face="Arial, Helvetica, sans-serif">this
is my page header</font></td>
</tr>
</table>
<TABLE WIDTH="695" BORDER="0">
<TR>
<tr>
</tr>
<TD VALIGN="top">
<TABLE WIDTH="195" BORDER="0" CELLSPACING="0" CELLPADDING="3">
<TR> <CFOUTPUT QUERY="fprdue" GROUP="exhibitornumber" STARTROW="1" MAXROWS=#rmax1#>
<TD WIDTH="195" ALIGN="center"> </TD>
</TR>
<cfoutput>
<TR>
<TD>#EX_Co_name# </TD>
<td>#Exhibitornumber#</td>
</TR>
<!--- determine last record shown in this column --->
<cfset count1 = #currentrow#>
</CFOUTPUT> </CFOUTPUT>
</TABLE>
<!--- column 2 --->
</TD>
<TD VALIGN="top">
<TABLE WIDTH="195" BORDER="0" CELLSPACING="0" CELLPADDING="3">
<TR>
<!--- <cfoutput>#count1# </CFOUTPUT> --->
<!--- column 2: startrow is last record of column 1 (=count1) +- 1 --->
<cfset srow2 = #count1# +- 1><cfoutput query="fprdue" GROUP="exhibitornumber" STARTROW=#srow2# MAXROWS=#rmax1#>
<TD WIDTH="195" ALIGN="center"> </TD>
</TR>
<cfoutput>
<TR>
<TD>
<!--- #currentrow# --->
#Ex_CO_name# </TD>
<td>#Exhibitornumber#</td>
</TR>
<!--- determine last record shown in this column --->
<cfset count2 = #currentrow#>
</CFOUTPUT> </CFOUTPUT>
</TABLE>
</TABLE>
</TD>
</TR>
</TABLE>
<br class="pageBreak">
</body>
</html>
I am still interested in helping.. just a little busy.. I will take a look at your code tonight.. if that is ok.
CJ
CJ
ASKER
thanks,
take a look at it when ever youget a chance.
I think I'm close but there is something missing.
take your time.
later
<listening>
take a look at it when ever youget a chance.
I think I'm close but there is something missing.
take your time.
later
<listening>
so you want the total rows just split into two columns?
CJ
CJ
let say your query returns 200 rows.
How many columns and rows would you expect to see per
page.
CJ
How many columns and rows would you expect to see per
page.
CJ
ASKER
ok.
a page (by my testing) will hold anywhere from 42-46 lines of data(Printed).
so if I am quering 2 fields id and name and the page will hold 42 -46 lines of data then if the recordset returned is total 200 then I would expect to see 84 - 92 records per page at a total colums of 2 0r 4
ie
with less than 42 records returned
id name
1 test1
2 test2
. .
42 test42
now with more than 42records returned.
id name id name
1 test1 43 test43
2 test2 44 test44
3 test3 45 test45
. . . .
42 test42 84 test84.
:)
a page (by my testing) will hold anywhere from 42-46 lines of data(Printed).
so if I am quering 2 fields id and name and the page will hold 42 -46 lines of data then if the recordset returned is total 200 then I would expect to see 84 - 92 records per page at a total colums of 2 0r 4
ie
with less than 42 records returned
id name
1 test1
2 test2
. .
42 test42
now with more than 42records returned.
id name id name
1 test1 43 test43
2 test2 44 test44
3 test3 45 test45
. . . .
42 test42 84 test84.
:)
try this:
<cfset numberOfRecordsBeforeHeade rDisplay = 42>
<cfset pageBreakCounter = 0>
<cfoutput query="yourQuery">
<!--- Display header --->
<cfif yourQuery.currentRow mod numberOfRecordsBeforeHeade rDisplay EQ 1>
<cfif pageBreakCounter eq 0>
<!-- start newspaper table -->
<table>
<tr>
</cfif>
<cfset pageBreakCounter = IncrementValue(pageBreakCo unter)>
<td>
<table>
<tr><td>... header html </td></tr>
</cfif>
<!--- table cell display --->
display your data here.
<!--- Display close table --->
<cfif yourQuery.currentRow mod numberOfRecordsBeforeHeade rDisplay EQ 0 OR yourQuery.currentRow EQ yourQuery.recordCount>
</table>
</td>
<cfif pageBreakCounter mod 2 eq 0 OR yourQuery.currentRow EQ yourQuery.recordCount>
<cfset pageBreakCounter = 0>
<!--- close newspaper table --->
</tr></table>
<!--- Insert your page break code here --->
</cfif>
</cfif>
</cfoutput>
I checked it out logically it seems to work.. but since I couldn't test it with real data.. I am not sure.
CJ
<cfset numberOfRecordsBeforeHeade
<cfset pageBreakCounter = 0>
<cfoutput query="yourQuery">
<!--- Display header --->
<cfif yourQuery.currentRow mod numberOfRecordsBeforeHeade
<cfif pageBreakCounter eq 0>
<!-- start newspaper table -->
<table>
<tr>
</cfif>
<cfset pageBreakCounter = IncrementValue(pageBreakCo
<td>
<table>
<tr><td>... header html </td></tr>
</cfif>
<!--- table cell display --->
display your data here.
<!--- Display close table --->
<cfif yourQuery.currentRow mod numberOfRecordsBeforeHeade
</table>
</td>
<cfif pageBreakCounter mod 2 eq 0 OR yourQuery.currentRow EQ yourQuery.recordCount>
<cfset pageBreakCounter = 0>
<!--- close newspaper table --->
</tr></table>
<!--- Insert your page break code here --->
</cfif>
</cfif>
</cfoutput>
I checked it out logically it seems to work.. but since I couldn't test it with real data.. I am not sure.
CJ
ASKER
thanks man I will let you know in the morn...
ok.. <waiting>
ASKER
cj,
sorry just been obe allof the day. Iwill let you know how it comes out shortly. (huff huff)
sorry just been obe allof the day. Iwill let you know how it comes out shortly. (huff huff)
ASKER
cj it is working fairly well, it is putting some white space on the top of the first 2 colums that is what I am trying to solve.
so far so good.
so far so good.
ok, keep me updated.
CJ
CJ
ASKER
what I have noticed is that no matter what I set the
"<cfset numberOfRecordsBeforeHeade rDisplay = 42>"
to I always have 2 records per each column cary over on to the second page leaving the remaider blank(second page) from then on all pages have the correct amount ofrecords and page breaks.
I'll keep you posted.
"<cfset numberOfRecordsBeforeHeade
to I always have 2 records per each column cary over on to the second page leaving the remaider blank(second page) from then on all pages have the correct amount ofrecords and page breaks.
I'll keep you posted.
ASKER
it has taken more time than anticipated.
can you explain your second last comment?
CJ
CJ
ASKER
not to fret,
I have resolved it, I am doing the last bit of testing (different amount of records returned) give me a lil I will let you know with in the next hour or so.
I have resolved it, I am doing the last bit of testing (different amount of records returned) give me a lil I will let you know with in the next hour or so.
ASKER
on the last page if the records dont add up to be what "<cfset numberOfRecordsBeforeHeade rDisplay = ??>" is set
it makes the cells stretch both width and height wise, similar to it justifing the page, and puts a lot of white space between and in front of the records:
this is what I have:
<style media="print">
BR.pageBreak { page-break-after: always }
</style>
<cfquery name="alphalist" datasource="exhibition">
Select *
from View_alphaXconame
</cfquery>
<cfset numberOfRecordsBeforeHeade rDisplay = 32>
<cfset pageBreakCounter = 0>
<cfoutput query="alphalist">
<!--- Display header --->
<cfif alphalist.currentRow mod numberOfRecordsBeforeHeade rDisplay EQ 1>
<cfif pageBreakCounter eq 0>
<!-- start newspaper table -->
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<cfinclude template="alphaheader.cfm" > <table width="100%" height="100%"">
<tr>
</cfif>
<cfset pageBreakCounter = IncrementValue(pageBreakCo unter)>
<td>
<table width="100%" height="90%">
<tr>
<td width="81%" valign="top" align="left">Name</td>
<td width="2%"> </td>
<td align="left" width="17%">Number </td>
</tr>
<td width="81%">
</cfif>
<!--- table cell display --->
<tr>
<td width="81%"><font face="Arial, Helvetica, sans-serif" size="2">#CO_Name#</font>< /td>
<td width="2%"> </td>
<td width="17%"><font face="Arial, Helvetica, sans-serif" size="2">#visitornumber#</ font></td>
</tr>
<!--- Display close table --->
<td width="81%">
<cfif alphalist.currentRow mod numberOfRecordsBeforeHeade rDisplay EQ 0 OR alphalist.currentRow EQ alphalist.recordCount>
</table>
</td>
<cfif pageBreakCounter mod 2 eq 0 OR alphalist.currentRow EQ alphalist.recordCount>
<cfset pageBreakCounter = 0>
<!--- close newspaper table --->
</table>
<br class="pageBreak">
</cfif>
</cfif>
</cfoutput>
it makes the cells stretch both width and height wise, similar to it justifing the page, and puts a lot of white space between and in front of the records:
this is what I have:
<style media="print">
BR.pageBreak { page-break-after: always }
</style>
<cfquery name="alphalist" datasource="exhibition">
Select *
from View_alphaXconame
</cfquery>
<cfset numberOfRecordsBeforeHeade
<cfset pageBreakCounter = 0>
<cfoutput query="alphalist">
<!--- Display header --->
<cfif alphalist.currentRow mod numberOfRecordsBeforeHeade
<cfif pageBreakCounter eq 0>
<!-- start newspaper table -->
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<cfinclude template="alphaheader.cfm"
<tr>
</cfif>
<cfset pageBreakCounter = IncrementValue(pageBreakCo
<td>
<table width="100%" height="90%">
<tr>
<td width="81%" valign="top" align="left">Name</td>
<td width="2%"> </td>
<td align="left" width="17%">Number </td>
</tr>
<td width="81%">
</cfif>
<!--- table cell display --->
<tr>
<td width="81%"><font face="Arial, Helvetica, sans-serif" size="2">#CO_Name#</font><
<td width="2%"> </td>
<td width="17%"><font face="Arial, Helvetica, sans-serif" size="2">#visitornumber#</
</tr>
<!--- Display close table --->
<td width="81%">
<cfif alphalist.currentRow mod numberOfRecordsBeforeHeade
</table>
</td>
<cfif pageBreakCounter mod 2 eq 0 OR alphalist.currentRow EQ alphalist.recordCount>
<cfset pageBreakCounter = 0>
<!--- close newspaper table --->
</table>
<br class="pageBreak">
</cfif>
</cfif>
</cfoutput>
ASKER
the spacing was being caused by a table cell height?
doesnt matter. I am appreciative of your help it looks like it worked wonderfully under stress.
it tested it by pulling 1500 records and agiain by pulling in increments of 35 +-1 and the pages held there formating and appearence.
I havent tested the loggin script yet?
do you mind if I try that out for a bit before I release the question.??
doesnt matter. I am appreciative of your help it looks like it worked wonderfully under stress.
it tested it by pulling 1500 records and agiain by pulling in increments of 35 +-1 and the pages held there formating and appearence.
I havent tested the loggin script yet?
do you mind if I try that out for a bit before I release the question.??
ASKER
this is what I have that checks the login stat
<cfset bLoggedIn = False>
<cfif IsDefined("Session.UserID" )>
<cfif Session.UserID neq "">
<cfset bLoggedIn = True>
</cfif>
<cfelse>
<cfif IsDefined("Cookie.UserID") >
<cfif Cookie.UserID neq "">
<cfset Session.UserID = Cookie.UserID>
<cfset bLoggedIn = True>
</cfif>
</cfif>
</cfif>
<!--- not in system --->
<cfif bLoggedIn eq False>
<cfinclude template="myErrorFile.cfm" >
<cfexit>
</cfif>
however whan I try to implement your suggested solution i cant seem to get it to work can you let me know where to place this?
<cfif notloggedin condition>
<cfset currentURL = "#CGI.Script_Name#?#CGI.Qu ery_String #">
<cflocation url="/path/to/login.cfm?re questedURL =" & URLEncodedFormat(currentUR L)>
</cfif>
<cfset bLoggedIn = False>
<cfif IsDefined("Session.UserID"
<cfif Session.UserID neq "">
<cfset bLoggedIn = True>
</cfif>
<cfelse>
<cfif IsDefined("Cookie.UserID")
<cfif Cookie.UserID neq "">
<cfset Session.UserID = Cookie.UserID>
<cfset bLoggedIn = True>
</cfif>
</cfif>
</cfif>
<!--- not in system --->
<cfif bLoggedIn eq False>
<cfinclude template="myErrorFile.cfm"
<cfexit>
</cfif>
however whan I try to implement your suggested solution i cant seem to get it to work can you let me know where to place this?
<cfif notloggedin condition>
<cfset currentURL = "#CGI.Script_Name#?#CGI.Qu
<cflocation url="/path/to/login.cfm?re
</cfif>
what is not working?
You place the :
<cfif notloggedin condition>
<cfset currentURL = "#CGI.Script_Name#?#CGI.Qu ery_String #">
<cflocation url="/path/to/login.cfm?re questedURL =" & URLEncodedFormat(currentUR L)>
</cfif>
at the top of each file.. ideally in a separate file as a cfinclude.
CJ
You place the :
<cfif notloggedin condition>
<cfset currentURL = "#CGI.Script_Name#?#CGI.Qu
<cflocation url="/path/to/login.cfm?re
</cfif>
at the top of each file.. ideally in a separate file as a cfinclude.
CJ
ASKER
that is what i am trying to accomplish.
I have placed this code in a seperate file and then included it on all my pages using cfinclude and what I get is if the user is not logged in it shows the cfinclude page and the requested page:
<cfset bLoggedIn = False>
<cfif IsDefined("Session.UserID" )>
<cfif Session.UserID neq "">
<cfset bLoggedIn = True>
</cfif>
<cfelse>
<cfif IsDefined("Cookie.UserID") >
<cfif Cookie.UserID neq "">
<cfset Session.UserID = Cookie.UserID>
<cfset bLoggedIn = True>
</cfif>
</cfif>
</cfif>
<cfif notloggedin condition>
<cfset currentURL = "#CGI.Script_Name#?#CGI.Qu ery_String #">
<cflocation url="/path/to/login.cfm?re questedURL =" & URLEncodedFormat(currentUR L)>
</cfif>
<!--- not in system --->
<cfif bLoggedIn eq False>
<cfinclude template="myErrorFile.cfm" >
<cfexit>
</cfif>
I have placed this code in a seperate file and then included it on all my pages using cfinclude and what I get is if the user is not logged in it shows the cfinclude page and the requested page:
<cfset bLoggedIn = False>
<cfif IsDefined("Session.UserID"
<cfif Session.UserID neq "">
<cfset bLoggedIn = True>
</cfif>
<cfelse>
<cfif IsDefined("Cookie.UserID")
<cfif Cookie.UserID neq "">
<cfset Session.UserID = Cookie.UserID>
<cfset bLoggedIn = True>
</cfif>
</cfif>
</cfif>
<cfif notloggedin condition>
<cfset currentURL = "#CGI.Script_Name#?#CGI.Qu
<cflocation url="/path/to/login.cfm?re
</cfif>
<!--- not in system --->
<cfif bLoggedIn eq False>
<cfinclude template="myErrorFile.cfm"
<cfexit>
</cfif>
Make this your include file:
<cfset bLoggedIn = False>
<cfif IsDefined("Session.UserID" )>
<cfif Session.UserID neq "">
<cfset bLoggedIn = True>
</cfif>
<cfelse>
<cfif IsDefined("Cookie.UserID") >
<cfif Cookie.UserID neq "">
<cfset Session.UserID = Cookie.UserID>
<cfset bLoggedIn = True>
</cfif>
</cfif>
</cfif>
<cfif bLoggedIn IS "False">
<cfset currentURL = "#CGI.Script_Name#?#CGI.Qu ery_String #">
<cflocation url="/path/to/login.cfm?re questedURL =" & URLEncodedFormat(currentUR L)>
</cfif>
CJ
<cfset bLoggedIn = False>
<cfif IsDefined("Session.UserID"
<cfif Session.UserID neq "">
<cfset bLoggedIn = True>
</cfif>
<cfelse>
<cfif IsDefined("Cookie.UserID")
<cfif Cookie.UserID neq "">
<cfset Session.UserID = Cookie.UserID>
<cfset bLoggedIn = True>
</cfif>
</cfif>
</cfif>
<cfif bLoggedIn IS "False">
<cfset currentURL = "#CGI.Script_Name#?#CGI.Qu
<cflocation url="/path/to/login.cfm?re
</cfif>
CJ
ASKER
error received
Invalid token found on line 16 at position 53. ColdFusion was looking at the following text:
&
where "&" is in
<cflocation url="default.cfm?requested URL=" & URLEncodedFormat(currentUR L)>
Invalid token found on line 16 at position 53. ColdFusion was looking at the following text:
&
where "&" is in
<cflocation url="default.cfm?requested
try this:
<cflocation url="default.cfm?requested URL=#URLEn codedForma t(currentU RL)#">
CJ
<cflocation url="default.cfm?requested
CJ
ASKER
cj when I try to jump into a page and the session has been ended I get a 404 object not found error. and this in the location bar:
default.cfm?requestedURL=% 2FDevelopm ent%2F0502 02%2Fvisio tor%2Fproc ess%2FVisi t%5FIns%2E cfm%3F&CFI D=86&CFTOK EN=2997312 .
default.cfm?requestedURL=%
is the login page called default.cfm?
Rename default.cfm to the page that handles your session ended/non logged in users.
CJ
Rename default.cfm to the page that handles your session ended/non logged in users.
CJ
ASKER
yes.
I have changed it to login2.cfm which checks for the session and nonlogged users with this:
<!--- Get user's details from the database --->
<cfquery name="GetUser" datasource="exhibition">
SELECT *
FROM Users
WHERE UserName = '#Form.UserName#'
AND Password = '#Form.Password#'
</cfquery>
<!--- Check if we have a winner! --->
<cfif GetUser.RecordCount gt 0>
<!--- Store the user id in session variables and cookies. --->
<cfset Session.userID = GetUser.UserID>
<cfcookie name="UserID" value="#GetUser.UserID#" expires="NOW">
<!--- If user exists, update his or her profile information --->
<!--- First get the old info - you may wish to use this somehow. Some of the login stats are --->
<!--- cumulative, so we add to the prior number, like TotalLogins--->
<cfset oldIP = getUser.LastIP>
<cfset oldBrowser = getUser.LastBrowser>
<cfset oldLogin = getUser.LastLogin>
<cfset TotLogins = getUser.TotalLogins>
<!--- Store the new info in variables --->
<cfset newIP = CGI.REMOTE_ADDR>
<cfset newBrowser = CGI.HTTP_USER_AGENT>
<cfset TotLogins = TotLogins + 1>
<cfquery Datasource="exhibition" name="UpdateUser">
UPDATE Users
SET TotalLogins = #TotLogins#,
LastIP = '#newIP#',
LastBrowser = '#newBrowser#',
LastLogin = #CreateODBCDateTime(Now()) #
WHERE UserID = #session.UserID#
</cfquery>
<cflocation url="index.cfm" addtoken="Yes">
<cfelse>
<!--- User does not exist --->
<!--- Pass the variables back in the URL - message and UserName --->
<cfset loginpage = "default.cfm?Message=" & URLEncodedFormat("Invalid User Name/Password Combination")>
<cfset loginpage = loginpage & "&UserName=" & URLEncodedFormat(#Form.Use rName#)>
<cflocation url="#loginpage#">
</cfif>
once I have changed it to this page I now get a
variable not defined error.?
I have changed it to login2.cfm which checks for the session and nonlogged users with this:
<!--- Get user's details from the database --->
<cfquery name="GetUser" datasource="exhibition">
SELECT *
FROM Users
WHERE UserName = '#Form.UserName#'
AND Password = '#Form.Password#'
</cfquery>
<!--- Check if we have a winner! --->
<cfif GetUser.RecordCount gt 0>
<!--- Store the user id in session variables and cookies. --->
<cfset Session.userID = GetUser.UserID>
<cfcookie name="UserID" value="#GetUser.UserID#" expires="NOW">
<!--- If user exists, update his or her profile information --->
<!--- First get the old info - you may wish to use this somehow. Some of the login stats are --->
<!--- cumulative, so we add to the prior number, like TotalLogins--->
<cfset oldIP = getUser.LastIP>
<cfset oldBrowser = getUser.LastBrowser>
<cfset oldLogin = getUser.LastLogin>
<cfset TotLogins = getUser.TotalLogins>
<!--- Store the new info in variables --->
<cfset newIP = CGI.REMOTE_ADDR>
<cfset newBrowser = CGI.HTTP_USER_AGENT>
<cfset TotLogins = TotLogins + 1>
<cfquery Datasource="exhibition" name="UpdateUser">
UPDATE Users
SET TotalLogins = #TotLogins#,
LastIP = '#newIP#',
LastBrowser = '#newBrowser#',
LastLogin = #CreateODBCDateTime(Now())
WHERE UserID = #session.UserID#
</cfquery>
<cflocation url="index.cfm" addtoken="Yes">
<cfelse>
<!--- User does not exist --->
<!--- Pass the variables back in the URL - message and UserName --->
<cfset loginpage = "default.cfm?Message=" & URLEncodedFormat("Invalid User Name/Password Combination")>
<cfset loginpage = loginpage & "&UserName=" & URLEncodedFormat(#Form.Use
<cflocation url="#loginpage#">
</cfif>
once I have changed it to this page I now get a
variable not defined error.?
you should redirect to the form page not the form submission page?
CJ
CJ
ASKER
Cj,
that is what I had done originaly when I redirected it to the default.cfm.? :(
that is what I had done originaly when I redirected it to the default.cfm.? :(
so you redirected to the login form page.. and then what?
You need to store the currentURL in a hidden form field so it gets passed to the form action page.
You should default the currentURL var to something in case it isn't passed in (like the default logged in main page)
CJ
You need to store the currentURL in a hidden form field so it gets passed to the form action page.
You should default the currentURL var to something in case it isn't passed in (like the default logged in main page)
CJ
ASKER
trying....
ASKER
CJ
Im lost...
could no figure it out, Im admiting defeat. :)
can you point me in the direction of an existing solution for this, because I am not comprehending.
Im lost...
could no figure it out, Im admiting defeat. :)
can you point me in the direction of an existing solution for this, because I am not comprehending.
could you outline what you want and your current code.
CJ
CJ
ASKER
CJ,
The code that I have now works fine for user login, the only thing that is missing is that when the session has expired and the user attemps to do something, they are taken to a screen that says that they must loggin once they loggin they are returned to the home page and have to go thru the same sequence of events to take them back to where they were. I have been trying(unsuccessfuly) to have them return to the page where the session has timed out once they log back in.I have been using a loggin script that I had aquired from the net. let me find the link and I will post that vs posting the 3 pages of code.
The code that I have now works fine for user login, the only thing that is missing is that when the session has expired and the user attemps to do something, they are taken to a screen that says that they must loggin once they loggin they are returned to the home page and have to go thru the same sequence of events to take them back to where they were. I have been trying(unsuccessfuly) to have them return to the page where the session has timed out once they log back in.I have been using a loggin script that I had aquired from the net. let me find the link and I will post that vs posting the 3 pages of code.
ASKER
cj,
here is the link to where I have gotten the original code for the loggin script(tutorial)(still need to learn more)
http://hotwired.lycos.com/webmonkey/00/48/index2a.html?tw=programming.
however I had never gotten the check authority to work properly.(See the previous comments) you helped me get it to work on this thread. using this:
<cfset bLoggedIn = False>
<cfif IsDefined("Session.UserID" )>
<cfif Session.UserID neq "">
<cfset bLoggedIn = True>
</cfif>
<cfelse>
<cfif IsDefined("Cookie.UserID") >
<cfif Cookie.UserID neq "">
<cfset Session.UserID = Cookie.UserID>
<cfset bLoggedIn = True>
</cfif>
</cfif>
</cfif>
<cfif bLoggedIn IS "False">
<cfset currentURL = "#CGI.Script_Name#?#CGI.Qu ery_String #">
<cflocation url="/path/to/login.cfm?re questedURL =" & URLEncodedFormat(currentUR L)>
</cfif>
now if you could help me out with the other functionality would just be peachy....
Thank a mil (again)
here is the link to where I have gotten the original code for the loggin script(tutorial)(still need to learn more)
http://hotwired.lycos.com/webmonkey/00/48/index2a.html?tw=programming.
however I had never gotten the check authority to work properly.(See the previous comments) you helped me get it to work on this thread. using this:
<cfset bLoggedIn = False>
<cfif IsDefined("Session.UserID"
<cfif Session.UserID neq "">
<cfset bLoggedIn = True>
</cfif>
<cfelse>
<cfif IsDefined("Cookie.UserID")
<cfif Cookie.UserID neq "">
<cfset Session.UserID = Cookie.UserID>
<cfset bLoggedIn = True>
</cfif>
</cfif>
</cfif>
<cfif bLoggedIn IS "False">
<cfset currentURL = "#CGI.Script_Name#?#CGI.Qu
<cflocation url="/path/to/login.cfm?re
</cfif>
now if you could help me out with the other functionality would just be peachy....
Thank a mil (again)
Wow... if you need help cj I can jump in but you have put a LOT of work in this one.
Nathan
http://www.cftipsplus.com
Nathan
http://www.cftipsplus.com
thanx nathans.. you can chime in if you want..
jriver12: please post your login.cfm code and the code that authenticates the user (the page that the login form posts to)
CJ
jriver12: please post your login.cfm code and the code that authenticates the user (the page that the login form posts to)
CJ
BTW: I am on the road for business so my responses might be a little slow during the week :-)
ASKER
from the login form page form action goes here.
<!--- Get user's details from the database --->
<cfquery name="GetUser" datasource="login">
SELECT *
FROM Users
WHERE UserName = '#Form.UserName#'
AND Password = '#Form.Password#'
</cfquery>
<!--- Check if we have a winner! --->
<cfif GetUser.RecordCount gt 0>
<!--- Store the user id in session variables and cookies. --->
<cfset Session.userID = GetUser.UserID>
<cfcookie name="UserID" value="#GetUser.UserID#" expires="NOW">
<!--- If user exists, update his or her profile information --->
<!--- First get the old info - you may wish to use this somehow. Some of the login stats are --->
<!--- cumulative, so we add to the prior number, like TotalLogins--->
<cfset oldIP = getUser.LastIP>
<cfset oldBrowser = getUser.LastBrowser>
<cfset oldLogin = getUser.LastLogin>
<cfset TotLogins = getUser.TotalLogins>
<!--- Store the new info in variables --->
<cfset newIP = CGI.REMOTE_ADDR>
<cfset newBrowser = CGI.HTTP_USER_AGENT>
<cfset TotLogins = TotLogins + 1>
<cfquery Datasource="exhibition" name="UpdateUser">
UPDATE Users
SET TotalLogins = #TotLogins#,
LastIP = '#newIP#',
LastBrowser = '#newBrowser#',
LastLogin = #CreateODBCDateTime(Now()) #
WHERE UserID = #session.UserID#
</cfquery>
<cflocation url="index.cfm" addtoken="Yes">
<cfelse>
<!--- User does not exist --->
<!--- Pass the variables back in the URL - message and UserName --->
<cfset loginpage = "default.cfm?Message=" & URLEncodedFormat("Invalid User Name/Password Combination")>
<cfset loginpage = loginpage & "&UserName=" & URLEncodedFormat(#Form.Use rName#)>
<cflocation url="#loginpage#">
</cfif>
then my include for all pages that checks to see if the user is logged in or sessionis still active is :
<cfset bLoggedIn = False>
<cfif IsDefined("Session.UserID" )>
<cfif Session.UserID neq "">
<cfset bLoggedIn = True>
</cfif>
<cfelse>
<cfif IsDefined("Cookie.UserID") >
<cfif Cookie.UserID neq "">
<cfset Session.UserID = Cookie.UserID>
<cfset bLoggedIn = True>
</cfif>
</cfif>
</cfif>
<cfif bLoggedIn IS "False">
<cfset currentURL = "#CGI.Script_Name#?#CGI.Qu ery_String #">
<cflocation url="login2.cfm?requestedU RL=#URLEnc odedFormat (currentUR L)#">
<!--- <cflocation url="default.cfm?requested URL=" & URLEncodedFormat(currentUR L)> --->
</cfif>
<!--- Get user's details from the database --->
<cfquery name="GetUser" datasource="login">
SELECT *
FROM Users
WHERE UserName = '#Form.UserName#'
AND Password = '#Form.Password#'
</cfquery>
<!--- Check if we have a winner! --->
<cfif GetUser.RecordCount gt 0>
<!--- Store the user id in session variables and cookies. --->
<cfset Session.userID = GetUser.UserID>
<cfcookie name="UserID" value="#GetUser.UserID#" expires="NOW">
<!--- If user exists, update his or her profile information --->
<!--- First get the old info - you may wish to use this somehow. Some of the login stats are --->
<!--- cumulative, so we add to the prior number, like TotalLogins--->
<cfset oldIP = getUser.LastIP>
<cfset oldBrowser = getUser.LastBrowser>
<cfset oldLogin = getUser.LastLogin>
<cfset TotLogins = getUser.TotalLogins>
<!--- Store the new info in variables --->
<cfset newIP = CGI.REMOTE_ADDR>
<cfset newBrowser = CGI.HTTP_USER_AGENT>
<cfset TotLogins = TotLogins + 1>
<cfquery Datasource="exhibition" name="UpdateUser">
UPDATE Users
SET TotalLogins = #TotLogins#,
LastIP = '#newIP#',
LastBrowser = '#newBrowser#',
LastLogin = #CreateODBCDateTime(Now())
WHERE UserID = #session.UserID#
</cfquery>
<cflocation url="index.cfm" addtoken="Yes">
<cfelse>
<!--- User does not exist --->
<!--- Pass the variables back in the URL - message and UserName --->
<cfset loginpage = "default.cfm?Message=" & URLEncodedFormat("Invalid User Name/Password Combination")>
<cfset loginpage = loginpage & "&UserName=" & URLEncodedFormat(#Form.Use
<cflocation url="#loginpage#">
</cfif>
then my include for all pages that checks to see if the user is logged in or sessionis still active is :
<cfset bLoggedIn = False>
<cfif IsDefined("Session.UserID"
<cfif Session.UserID neq "">
<cfset bLoggedIn = True>
</cfif>
<cfelse>
<cfif IsDefined("Cookie.UserID")
<cfif Cookie.UserID neq "">
<cfset Session.UserID = Cookie.UserID>
<cfset bLoggedIn = True>
</cfif>
</cfif>
</cfif>
<cfif bLoggedIn IS "False">
<cfset currentURL = "#CGI.Script_Name#?#CGI.Qu
<cflocation url="login2.cfm?requestedU
<!--- <cflocation url="default.cfm?requested
</cfif>
I also need the login form page code.
CJ
CJ
ASKER
Sorry,
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Login to Access Your Account</title>
</head>
<cfset pagecaption ="You must Login to Proceed!">
<cfinclude template="htmlheader.cfm">
<body bgcolor="#FFFFCC" text="#000000" link="#333333" vlink="#333333" alink="#333333">
<font face="Verdana, Arial, Helvetica">
<h4>Login to the U.S. Poultry & Egg Association's Exhibitor Management System:</h4>
<p>
<cfif IsDefined("URL.Message")>
<cfoutput><b>#URL.Message# </b></cfou tput>
</cfif>
<cfform action="login2.cfm" method="post">
<cfif IsDefined("URL.UserName")>
<b>User Name:</b>
<cfinput type="Text" required="Yes" message="Please Enter a User Name" name="UserName" maxlength="10" value="#URL.UserName#">
<cfelse>
<b>User Name:</b>
<cfinput type="Text" required="Yes" message="Please Enter a User Name" name="UserName" maxlength="10">
</cfif>
<p> <b>Password:</b>
<cfinput type="Password" required="Yes" message="Please Enter a Password" name="Password" maxlength="8">
<p>
<input type="submit" value="Login!">
</cfform>
</font>
<cfinclude template="HtmlFooter.cfm">
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Login to Access Your Account</title>
</head>
<cfset pagecaption ="You must Login to Proceed!">
<cfinclude template="htmlheader.cfm">
<body bgcolor="#FFFFCC" text="#000000" link="#333333" vlink="#333333" alink="#333333">
<font face="Verdana, Arial, Helvetica">
<h4>Login to the U.S. Poultry & Egg Association's Exhibitor Management System:</h4>
<p>
<cfif IsDefined("URL.Message")>
<cfoutput><b>#URL.Message#
</cfif>
<cfform action="login2.cfm" method="post">
<cfif IsDefined("URL.UserName")>
<b>User Name:</b>
<cfinput type="Text" required="Yes" message="Please Enter a User Name" name="UserName" maxlength="10" value="#URL.UserName#">
<cfelse>
<b>User Name:</b>
<cfinput type="Text" required="Yes" message="Please Enter a User Name" name="UserName" maxlength="10">
</cfif>
<p> <b>Password:</b>
<cfinput type="Password" required="Yes" message="Please Enter a Password" name="Password" maxlength="8">
<p>
<input type="submit" value="Login!">
</cfform>
</font>
<cfinclude template="HtmlFooter.cfm">
</body>
</html>
Sorry it took so long.. try this out:
include file to check if user is logged in:
<cfset bLoggedIn = False>
<cfif IsDefined("Session.UserID" )>
<cfif Session.UserID neq "">
<cfset bLoggedIn = True>
</cfif>
<cfelse>
<cfif IsDefined("Cookie.UserID") >
<cfif Cookie.UserID neq "">
<cfset Session.UserID = Cookie.UserID>
<cfset bLoggedIn = True>
</cfif>
</cfif>
</cfif>
<cfif bLoggedIn IS "False">
<cfset currentURL = "#CGI.Script_Name#?#CGI.Qu ery_String #">
<cflocation url="default.cfm?requested URL=#URLEn codedForma t(currentU RL)#">
<!--- <cflocation url="default.cfm?requested URL=" & URLEncodedFormat(currentUR L)> --->
</cfif>
default.cfm:
<html>
<head>
<title>Login to Access Your Account</title>
</head>
<cfset pagecaption ="You must Login to Proceed!">
<cfinclude template="htmlheader.cfm">
<body bgcolor="#FFFFCC" text="#000000" link="#333333" vlink="#333333" alink="#333333">
<font face="Verdana, Arial, Helvetica">
<h4>Login to the U.S. Poultry & Egg Association's Exhibitor Management System:</h4>
<p>
<cfif IsDefined("URL.Message")>
<cfoutput><b>#URL.Message# </b></cfou tput>
</cfif>
<cfform action="login2.cfm" method="post">
<cfif IsDefined("URL.UserName")>
<b>User Name:</b>
<cfinput type="Text" required="Yes" message="Please Enter a User Name" name="UserName" maxlength="10"
value="#URL.UserName#">
<cfelse>
<b>User Name:</b>
<cfinput type="Text" required="Yes" message="Please Enter a User Name" name="UserName" maxlength="10">
</cfif>
<p> <b>Password:</b>
<cfinput type="Password" required="Yes" message="Please Enter a Password" name="Password" maxlength="8">
<p>
<cfparam name="URL.requestedURL" default="">
<input type="hidden" name="requestedURL" value="<cfoutput>#URL.requ estedURL#< /cfoutput> ">
<input type="submit" value="Login!">
</cfform>
</font>
<cfinclude template="HtmlFooter.cfm">
</body>
</html>
login2.cfm:
<cfif isDefined("FORM.requestedU RL")>
<cfset VARIABLES.requestedURL = FORM.requestedURL>
<cfelse>
<cfset VARIABLES.requestedURL = "index.cfm">
</cfif>
<!--- Get user's details from the database --->
<cfquery name="GetUser" datasource="login">
SELECT *
FROM Users
WHERE UserName = '#Form.UserName#'
AND Password = '#Form.Password#'
</cfquery>
<!--- Check if we have a winner! --->
<cfif GetUser.RecordCount gt 0>
<!--- Store the user id in session variables and cookies. --->
<cfset Session.userID = GetUser.UserID>
<cfcookie name="UserID" value="#GetUser.UserID#" expires="NOW">
<!--- If user exists, update his or her profile information --->
<!--- First get the old info - you may wish to use this somehow. Some of the login stats are --->
<!--- cumulative, so we add to the prior number, like TotalLogins--->
<cfset oldIP = getUser.LastIP>
<cfset oldBrowser = getUser.LastBrowser>
<cfset oldLogin = getUser.LastLogin>
<cfset TotLogins = getUser.TotalLogins>
<!--- Store the new info in variables --->
<cfset newIP = CGI.REMOTE_ADDR>
<cfset newBrowser = CGI.HTTP_USER_AGENT>
<cfset TotLogins = TotLogins + 1>
<cfquery Datasource="exhibition" name="UpdateUser">
UPDATE Users
SET TotalLogins = #TotLogins#,
LastIP = '#newIP#',
LastBrowser = '#newBrowser#',
LastLogin = #CreateODBCDateTime(Now()) #
WHERE UserID = #session.UserID#
</cfquery>
<cflocation url="#VARIABLES.requestedU RL#" addtoken="Yes">
<cfelse>
<!--- User does not exist --->
<!--- Pass the variables back in the URL - message and UserName --->
<cfset loginpage = "default.cfm?Message=" & URLEncodedFormat("Invalid User Name/Password Combination")>
<cfset loginpage = loginpage & "&UserName=" & URLEncodedFormat(#Form.Use rName#)
& "&requestedURL=" & URLEncodedFormat(VARIABLES .requested URL)>
<cflocation url="#loginpage#">
</cfif>
HTH,
CJ
include file to check if user is logged in:
<cfset bLoggedIn = False>
<cfif IsDefined("Session.UserID"
<cfif Session.UserID neq "">
<cfset bLoggedIn = True>
</cfif>
<cfelse>
<cfif IsDefined("Cookie.UserID")
<cfif Cookie.UserID neq "">
<cfset Session.UserID = Cookie.UserID>
<cfset bLoggedIn = True>
</cfif>
</cfif>
</cfif>
<cfif bLoggedIn IS "False">
<cfset currentURL = "#CGI.Script_Name#?#CGI.Qu
<cflocation url="default.cfm?requested
<!--- <cflocation url="default.cfm?requested
</cfif>
default.cfm:
<html>
<head>
<title>Login to Access Your Account</title>
</head>
<cfset pagecaption ="You must Login to Proceed!">
<cfinclude template="htmlheader.cfm">
<body bgcolor="#FFFFCC" text="#000000" link="#333333" vlink="#333333" alink="#333333">
<font face="Verdana, Arial, Helvetica">
<h4>Login to the U.S. Poultry & Egg Association's Exhibitor Management System:</h4>
<p>
<cfif IsDefined("URL.Message")>
<cfoutput><b>#URL.Message#
</cfif>
<cfform action="login2.cfm" method="post">
<cfif IsDefined("URL.UserName")>
<b>User Name:</b>
<cfinput type="Text" required="Yes" message="Please Enter a User Name" name="UserName" maxlength="10"
value="#URL.UserName#">
<cfelse>
<b>User Name:</b>
<cfinput type="Text" required="Yes" message="Please Enter a User Name" name="UserName" maxlength="10">
</cfif>
<p> <b>Password:</b>
<cfinput type="Password" required="Yes" message="Please Enter a Password" name="Password" maxlength="8">
<p>
<cfparam name="URL.requestedURL" default="">
<input type="hidden" name="requestedURL" value="<cfoutput>#URL.requ
<input type="submit" value="Login!">
</cfform>
</font>
<cfinclude template="HtmlFooter.cfm">
</body>
</html>
login2.cfm:
<cfif isDefined("FORM.requestedU
<cfset VARIABLES.requestedURL = FORM.requestedURL>
<cfelse>
<cfset VARIABLES.requestedURL = "index.cfm">
</cfif>
<!--- Get user's details from the database --->
<cfquery name="GetUser" datasource="login">
SELECT *
FROM Users
WHERE UserName = '#Form.UserName#'
AND Password = '#Form.Password#'
</cfquery>
<!--- Check if we have a winner! --->
<cfif GetUser.RecordCount gt 0>
<!--- Store the user id in session variables and cookies. --->
<cfset Session.userID = GetUser.UserID>
<cfcookie name="UserID" value="#GetUser.UserID#" expires="NOW">
<!--- If user exists, update his or her profile information --->
<!--- First get the old info - you may wish to use this somehow. Some of the login stats are --->
<!--- cumulative, so we add to the prior number, like TotalLogins--->
<cfset oldIP = getUser.LastIP>
<cfset oldBrowser = getUser.LastBrowser>
<cfset oldLogin = getUser.LastLogin>
<cfset TotLogins = getUser.TotalLogins>
<!--- Store the new info in variables --->
<cfset newIP = CGI.REMOTE_ADDR>
<cfset newBrowser = CGI.HTTP_USER_AGENT>
<cfset TotLogins = TotLogins + 1>
<cfquery Datasource="exhibition" name="UpdateUser">
UPDATE Users
SET TotalLogins = #TotLogins#,
LastIP = '#newIP#',
LastBrowser = '#newBrowser#',
LastLogin = #CreateODBCDateTime(Now())
WHERE UserID = #session.UserID#
</cfquery>
<cflocation url="#VARIABLES.requestedU
<cfelse>
<!--- User does not exist --->
<!--- Pass the variables back in the URL - message and UserName --->
<cfset loginpage = "default.cfm?Message=" & URLEncodedFormat("Invalid User Name/Password Combination")>
<cfset loginpage = loginpage & "&UserName=" & URLEncodedFormat(#Form.Use
& "&requestedURL=" & URLEncodedFormat(VARIABLES
<cflocation url="#loginpage#">
</cfif>
HTH,
CJ
ASKER
CJ,
when the session is expired and an action is taken that would take you to another page I get the following error.
Error Occurred While Processing Request
Error Diagnostic Information
An error has occurred.
HTTP/1.0 404 Object Not Found
now with in that looking at the debug info I see something that caught my eye.
1. HTTP_REFERER=http://Development/052302/visitor/process/Ex_update.cfm?visitornumber=12&Ex_Comp_to=NA
2. QUERY_STRING=requestedURL= %2FDevelop ment%2F052 302%2Fvisi tor%2Fproc ess%2FEx%5 Fupdate%2E cfm%3F&CFI D=99&CFTOK EN=7591491
3. this is the one that I think is causing the problem but I don't know how to resolve it.
SCRIPT_NAME=/Development/0 52302/Exhi bitor/proc ess/defaul t.cfm
there is no file named default in that directory the only default.cfm in the entire app resides off the root.
thanks
when the session is expired and an action is taken that would take you to another page I get the following error.
Error Occurred While Processing Request
Error Diagnostic Information
An error has occurred.
HTTP/1.0 404 Object Not Found
now with in that looking at the debug info I see something that caught my eye.
1. HTTP_REFERER=http://Development/052302/visitor/process/Ex_update.cfm?visitornumber=12&Ex_Comp_to=NA
2. QUERY_STRING=requestedURL=
3. this is the one that I think is causing the problem but I don't know how to resolve it.
SCRIPT_NAME=/Development/0
there is no file named default in that directory the only default.cfm in the entire app resides off the root.
thanks
I thought your login page was called default.cfm?
the page that has the login form.. where is that at?
the page that has the login form.. where is that at?
ASKER
You are correct it is called defaut.cfm(contains the form),
login2.cfm does all the processign, and the include checks and redirects.
for what I am seeing I think that once the app sences that the session has ended. and sends you back to the default .cfm, and the user logs in. it is trying to send them back to the same directory but keeping the defaul.cfm as the page to look for.
the requested url at sessionclosing was "REQUESTEDURL=/Development /052302/Ex hibitor/pr ocess/Ex_u pdate.cfm? "
but the page that is being requested after logging in again is =/Development/052302/Exhib itor/proce ss/default .cfm.
when there is no default.cfm in that directory it is at
Development/052302/
login2.cfm does all the processign, and the include checks and redirects.
for what I am seeing I think that once the app sences that the session has ended. and sends you back to the default .cfm, and the user logs in. it is trying to send them back to the same directory but keeping the defaul.cfm as the page to look for.
the requested url at sessionclosing was "REQUESTEDURL=/Development
but the page that is being requested after logging in again is =/Development/052302/Exhib
when there is no default.cfm in that directory it is at
Development/052302/
then change the code at two spots to wherever the correct login page is.. give an absolute url (since cflocation cannot take relative paths)
the first spot is in the included code.. where the cflocation tag is... change the default.cfm (that part only) there to the full path to default.cfm
the second spot is in login2.cfm: change the cflocation that is at the end of the <cfelse> portion of the code as the same as above.. so change the default.cfm (that part only) to the absolute path to default.cfm
CJ
the first spot is in the included code.. where the cflocation tag is... change the default.cfm (that part only) there to the full path to default.cfm
the second spot is in login2.cfm: change the cflocation that is at the end of the <cfelse> portion of the code as the same as above.. so change the default.cfm (that part only) to the absolute path to default.cfm
CJ
ASKER
Cj I don't think that is the issue(in my newbie opinion).
I am going to try to out line what I have just discoverd be patient.
1 user get to site and are not logged in so the have to be logged in. they do so at default.cfm(submit)
2. during the submit process we go to login2.cfm which does a multiple of things 1 of which is to make sure that the user exist in the db. in this case we have a winner (so we proceed to the index.cfm)
3. at index.cfm the user elects to update a record, so they are taken to somedir\someplace\inanothe rfolder\up date.cfm.( the record is now ready for update all changes made.)(submit)
4. (here is where I die) I have waited for the session to expire before hitting the submit, hence the scripts takeover and take me back to default.cfm, and in the location bar we see:
http://Development/052302/Exhibitor/process/default.cfm?requestedURL=%2FDevelopment%2F052302%2FExhibitor%2Fprocess%2FEx%5Fupdate%2Ecfm%3F&CFID=99&CFTOKEN=7591491
only one problem:
the above url is where I was but my url.varialble that I passed to get there has been striped.
so my actual url should be:
http://Development/052302/Exhibitor/process/default.cfm?requestedURL=%2FDevelopment%2F052302%2FExhibitor%2Fprocess%2FEx%5Fupdate%2Ecfm%3Fexhibitornumber%3D12%26Ex%5FComp%5Fto%3DNA&CFID=99&CFTOKEN=7591491
which upon successfuly loging in again I am taken back to the page to where I would have hit the submit button for the record to be updated.
How did I get this url.?
I hit the back button by accident and had realized that the url had change a bit.
now I think the bit of code that controls this if I am not mistaken is
here in login2.cfm
<cfif isDefined("FORM.requestedU RL")>
<cfset VARIABLES.requestedURL = FORM.requestedURL>
<cfelse>
<cfset VARIABLES.requestedURL = "index.cfm">
</cfif>
now on that submit button I had an action of :>#CGI.Script_Name# (notice the non exsitance of url variables) now this may be the issue but I am not sure so let me test it and I will let you know.
if you have any other sugestions let me know.
I am going to try to out line what I have just discoverd be patient.
1 user get to site and are not logged in so the have to be logged in. they do so at default.cfm(submit)
2. during the submit process we go to login2.cfm which does a multiple of things 1 of which is to make sure that the user exist in the db. in this case we have a winner (so we proceed to the index.cfm)
3. at index.cfm the user elects to update a record, so they are taken to somedir\someplace\inanothe
4. (here is where I die) I have waited for the session to expire before hitting the submit, hence the scripts takeover and take me back to default.cfm, and in the location bar we see:
http://Development/052302/Exhibitor/process/default.cfm?requestedURL=%2FDevelopment%2F052302%2FExhibitor%2Fprocess%2FEx%5Fupdate%2Ecfm%3F&CFID=99&CFTOKEN=7591491
only one problem:
the above url is where I was but my url.varialble that I passed to get there has been striped.
so my actual url should be:
http://Development/052302/Exhibitor/process/default.cfm?requestedURL=%2FDevelopment%2F052302%2FExhibitor%2Fprocess%2FEx%5Fupdate%2Ecfm%3Fexhibitornumber%3D12%26Ex%5FComp%5Fto%3DNA&CFID=99&CFTOKEN=7591491
which upon successfuly loging in again I am taken back to the page to where I would have hit the submit button for the record to be updated.
How did I get this url.?
I hit the back button by accident and had realized that the url had change a bit.
now I think the bit of code that controls this if I am not mistaken is
here in login2.cfm
<cfif isDefined("FORM.requestedU
<cfset VARIABLES.requestedURL = FORM.requestedURL>
<cfelse>
<cfset VARIABLES.requestedURL = "index.cfm">
</cfif>
now on that submit button I had an action of :>#CGI.Script_Name# (notice the non exsitance of url variables) now this may be the issue but I am not sure so let me test it and I will let you know.
if you have any other sugestions let me know.
the include code should handle that. It should append both the current URL and query string and make it a part of the requestedURL parameter.
I am not sure I follow how the code is behaving vs. the desired behavior.
could you paint out two scenarios. Starting from the user trying to access a page with an expired session.
first scenario: what is actually going on.
second scenario: what should happen.
Thanx,
CJ
I am not sure I follow how the code is behaving vs. the desired behavior.
could you paint out two scenarios. Starting from the user trying to access a page with an expired session.
first scenario: what is actually going on.
second scenario: what should happen.
Thanx,
CJ
ASKER
thanks for bearing with me.
what I have done so far to by pass this issue is to copy the authenticate,default, and login2.cfm to each individual folder(temp fix) till either I figure out what I'm doing or till I learn to explain the cituation.
here we go:
1st scenario:
Path to edit.cfm = \recordedit\type\thisone\e dit.cfm
Path to the login2,authenticate,and default.cfm = \
the user is at a record update screen(edit.cfm), now the session is timed out when they submit the record for update they should get a login screen that tell them to log back in. it should take them back to \default.cfm, but it is not it is going to \recordedit\type\thisone\d efault.cfm
where the default.cfm does not exist.
2nd scenario:(using same structure as above)
what should happen is that once the session is ended and an action is attempted the user should be taken to the default.cfm page so they may log in, then once the login is successful it should continue with the processing of the update or action that was requested prior to the reestablishment of the session with the login.
what I have done so far to by pass this issue is to copy the authenticate,default, and login2.cfm to each individual folder(temp fix) till either I figure out what I'm doing or till I learn to explain the cituation.
here we go:
1st scenario:
Path to edit.cfm = \recordedit\type\thisone\e
Path to the login2,authenticate,and default.cfm = \
the user is at a record update screen(edit.cfm), now the session is timed out when they submit the record for update they should get a login screen that tell them to log back in. it should take them back to \default.cfm, but it is not it is going to \recordedit\type\thisone\d
where the default.cfm does not exist.
2nd scenario:(using same structure as above)
what should happen is that once the session is ended and an action is attempted the user should be taken to the default.cfm page so they may log in, then once the login is successful it should continue with the processing of the update or action that was requested prior to the reestablishment of the session with the login.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
CJ, it looks like it is working. :)
would you mind if I apply it to all the pages that I need them in and I will release the question.?
would you mind if I apply it to all the pages that I need them in and I will release the question.?
its working? great!
Do whatever you want with the code.. I am just glad you got it to work :-)
CJ
Do whatever you want with the code.. I am just glad you got it to work :-)
CJ
ASKER
I didn't you did
thanks a mil.
enjoy the long weekend (if you are like most of we don't get much of those)
thanks a mil.
enjoy the long weekend (if you are like most of we don't get much of those)
tell me about it.. I have to travel for biz on Tuesday.. so I am going to really enjoy this rare time to relax :-)
CJ
CJ
ASKER
yup yup!
ASKER
CJ,
i have been running the script for a day and change now and all looks good.
thanks for bearing with me i realy do appreciate it.
I had in the past tried to follow nathans newsletters on logins but got lost in the translation.
however thanks you all who contributed to this thread.
i have been running the script for a day and change now and all looks good.
thanks for bearing with me i realy do appreciate it.
I had in the past tried to follow nathans newsletters on logins but got lost in the translation.
however thanks you all who contributed to this thread.
ASKER
nathan thanks for listening in once I saw you where listening I went back into my newsletters and found some that where promising but to advanced for me to follow thanks for the offer of helping and please keep sending out the news letter people like me realy learn from and enjoy those newsletters.
thanks.
thanks.
ASKER
works wonderfully,
I will let you know how it does under stress.
I will let you know how it does under stress.
Glad it worked for ya. Thanx for the "A".
Keep me updated on the perf side of things.
CJ
Keep me updated on the perf side of things.
CJ
ASKER
I did have to make 1 modification.
why
when I put it on the server it was having a hard time finding the Default.cfm(it would time out)no matter what path i gave, so....
I forced my browser to look at another page index.cfm which in return had the include that checks for user and session and being that it was no there I then rediredted to default.
works like a charm so far.
why
when I put it on the server it was having a hard time finding the Default.cfm(it would time out)no matter what path i gave, so....
I forced my browser to look at another page index.cfm which in return had the include that checks for user and session and being that it was no there I then rediredted to default.
works like a charm so far.
where you check if the user is logged in...
do this..
<cfif notloggedin condition>
<cfset currentURL = "#CGI.Script_Name#?#CGI.Qu
<cflocation url="/path/to/login.cfm?re
</cfif>
Now login.cfm should use URL.requestedURL to redirect the user back to their original requested URL.
for pagination:
http://www.teratech.com/ColdCuts/cutdetail.cfm?cutid=163
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=14&lngWId=9
CJ