Reply to topic
Domain sub folder links .. please help
luckywilly


Joined: 19 Apr 2004
Posts: 1
Reply with quote
Hi, I currently have a site with members and each member wants a direct link to their own information page. The way that I was hoping to do it is something like this : http://www.domain.com/username .. the way that i thought of is creating a subfolder for each member and just place a index.cfm file that queries the database to show their information. Can anyone know of a way that i can just points to one file and queries the database accordingly depending on the username, without have to create subfolders ? I mean if no subfolder there would be an error message .. Can anyone help ?? Thank You Idea
MBMunday


Joined: 06 Apr 2004
Posts: 76
Location: Dallas/Fort Worth
Reply with quote
I don't see a need at all to create subfolder for each member. You can use ColdFusion's session variables to see who the user is and query the database accordingly. Do you already have a password protected area/login form using ColdFusion?

Here is some old login code that I've used in the past (There may be a better way to do it now, but I know this works):

Login page:

<CFPARAM name="LoginSubmit" default="">
<CFPARAM name="username" default="">
<CFPARAM name="pwd" default="">
<!--- check form variables to see if user is in db --->
<CFIF LoginSubmit EQUAL "Login">
<CFQUERY name="login" DATASOURCE="#dsn#">
SELECT *
FROM users
WHERE UserName='#username#'
AND Pwd = '#pwd#'
</CFQUERY>
<!--- set users session variables --->
<CFIF Login.recordcount gt 0>
<CFSET session.user="#login.username#">
<CFSET session.accesslevel="#login.accesslevel#">
<CFSET session.fullname="#login.firstname# #login.lastname#">
<CFSET session.name="#login.firstname#">
<CFSET session.userID="#login.userID#">
</CFIF>

Along with your other code and your Application.cfm file, create a session based on the users details once they login. The above query accesses all the users information (via the SELECT * ) from the db, so you can create a session for that user.

Then, when you want to create query for the user to retrieve their specific information, do something like this:

<cfquery name="getUserData" datasource="#dsn#">
Select *
FROM users
WHERE userid = #session.userID#
</cfquery>

Note - this is VERY IMCOMPLETE code, so if this little tidbit doesn't help you, or confuses you, send me an Private Message or an email and I'll provide you with a much more detailed example.

MB
waterswing


Joined: 27 Apr 2004
Posts: 4
Reply with quote
Hello,

I've done what you are asking, with creating subfolders for each user, and beleive me, you don't want to do that. It's a nightmare to maintain. What you want to do is to check if you can your own error pages - and put the necasary logic in there.
Domain sub folder links .. please help
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT  
Page 1 of 1  

  
  
 Reply to topic