Copy link to clipboard
Copied
I have a login system that works great when the application, userloginform, forceuserlogin, etc are in the same folder.
I would like to have the main page of a website, say sample.com have a login form. If the login is correct, that it redirects to
a subdomain, such as sample.com/members.
This is my current login form. I am assuming that the action needs to change, but I have no idea how to pass the username and password to the sample.com/members/forceuserlogin.cfm to log the user in.
Any thoughts? I am a beginner to CF, so any help would be MUCH appreciated. Thanks!!
<table width="239">
<cfform name="LoginForm" format="html" timeout="10000" method="POST" preservedata="Yes" action="#CGI.SCRIPT_NAME#" >
<tr>
<td width="26" rowspan="4"></td>
</tr>
<tr>
<td width="117"><p>Username</p></td>
<td width="80"><cfinput name="username" type="text" width="75"></td>
</tr>
<tr>
<td width="117"><p>Password</p></td>
<td><cfinput name="password" type="password" width="75"></td>
</tr>
<tr>
<td colspan="2" align="right"><cfinput name="Submit" type="Submit" value="Login" ></td>
</tr>
</cfform>
Copy link to clipboard
Copied
Under your CFForm tag the Action attributes should be calling the action page that process the UserID and Password.
From the action page you should have a query to verify username and Password something like this:
<CFQUERY name="UseridQuery" datasource="UserTable">
SELECT * FROM User
Where username='#Form.username#'
and Password='#Form.Password#'
</CFQUERY>
You then should have an if statement to check to see if the query return a record is this:
<CFIF UseridQuery.RecordCount is 0>
This section you do error checking to have them enter the correct username and Password.
<CFELSE>
Here is where you will let the user pass and display the page you want the users to see by using <CFLOCATION url="display.cfm">
</CFIF>
Hope this help!!