Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Login/Creating User Accounts/Intranet Project

Status
Not open for further replies.

gmagerr

Technical User
Aug 11, 2001
323
US
Good Morning everyone. Ok, this is gonna be long. I've created an Intranet site for my company in .asp using Macromedia UltraDev. I've recently obtained a calendar dayplanner thingie that's in coldfusion. My boss loves it, and wants me to redo the site in coldfusion (i'd like to learn CF anyway). I've transfered most of the simple pages over to CF, now i have some things i need help with. I have a login page that comes up when you try to login to the intranet site. There's username and password textboxes (nothing exciting yet) enter your username and password and it checks to see if you're in the database, if you are it'll send you to the default.cfm in the intranet site. (ok so far) Here's where i'm getting messed up. I want it to do this.. If you enter a name and pass that's not in the database, I want it to go to a create account page where you can create an account for the intranet. Also if you do have an account and you just forgot your password, i'd like to have a form that comes up so you can enter your username and it will send an email to you with your username and password from the database. I've dome all this like i said in .asp using CDONTS and VBSCRIPT i'd love for someone to show me how to do it in CF. From what i hear it's supposed to be much easier. Oh one more thing, when a user logs in i'd like a variable set so on the other pages i can put stuff like Hello:UserName or something like that. Ok thanks that'll do for a start :)
 
A couple of tricks you can maybe use:

First, check to see if the environment variable #REMOTE_USER# has a value. If it does, and if your company's e-mail and network logons follow a set design, like first initial plus last name, you can create e-mail addresses from that variable. For example, suppose #REMOTE_USER# IS "mydomain/jhoarty" (it should be your domain followed by the user's login id). Then the user's login will always be
<cfset thisuser = #REMOTE_USER#>
<cfset loginlen = (LEN(thisuser) - 9)>
since there are 9 characters in &quot;mydomain/&quot;
<cfset thislogin = #RIGHT(thisuser, loginlen)#>

You can now create the user's e-mail address simply by appending the rest of your company e-mail formula to the login.

<cfset useremail = &quot;#thislogin#@mydomain.com&quot;>

Otherwise, you can just store the user's login in the authentication database you are using. You said it contained login and password. Are you by chance using e-mail as the login?

Anyway, One way or another you want to be able to send passwords to e-mail addresses. On account setup, you can set a cookie to the user's e-mail address like this:

<CFCOOKIE NAME=&quot;valid_user&quot; VALUE=&quot;#useremail#&quot; EXPIRES=&quot;NEVER&quot;>

Then, if someone clicks your &quot;I forgot my e-mail&quot; link, you can query up their password using their e-mail address, if you are keeping that, too. Something like:

<cfquery datasource=&quot;#datasource#&quot; name=&quot;sendpass&quot;>
SELECT password from UserTable
WHERE email = '#cookie.valid_user#'
</cfquery>

Again, this assumes you are keeping username, password and e-mail in that table.

Finally, on unsuccesful login, you want to create a new account page. Just do your lookup and cfinclude the new account page when the lookup returns no results.

<cfquery datasource=&quot;#datasource#&quot; name=&quot;getuser&quot;>
SELECT * FROM UserTable
WHERE username = '#form.login#'
AND pass = '#form.password#'
</cfquery>

<cfif #getuser.recordcount# IS 0>
<cfinclude template=&quot;new_account.cfm&quot;>
<cfelse>
<cfinclude template=&quot;welcome.cfm&quot;>
</cfif>



John Hoarty
jhoarty@quickestore.com
 
Hah! hi gmagerr

Start slow. Can you get ColdFusion to access the same database? If you're that far, all you need to learn is CFQUERY, CFOUTPUT, CFIF, CFLOCATION, SQL (if not already complete), and CFMAIL which is very simple.

As for the variable stored accross pages, using session management will be good. In your application.cfm use

<CFAPPLICATION sessionmanagement=&quot;yes&quot; sessiontimeout=&quot;#createtimespan(0,0,1,0)#&quot;>

Then set a variable using <CFSET session.myvar = &quot;Jack Black&quot;>

good luck
 
Thanks guys, I will try your suggestions, they make sense. is there a resource that has a listing of the CF tags and such? Anything at this point is a major help.
 
give me your e-mail, I'll e-mail some good materials for starters

dsylvano@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top