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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I need help with passing a password and username to another page

Status
Not open for further replies.

WebGodiva

Technical User
Jun 21, 2000
263
0
0
US
I have setup two files, one a simple HTML form which should pass the username and password to the second file (a cf file) which should verify the names against the access database and either allow access or not.<br><br>the code is as follows for the HTML file:<br><br>&lt;html&gt;<br>&lt;head&gt;<br> &lt;title&gt;SITE-Blauvelt Employee Intranet Authorization Page&lt;/title&gt;<br>&lt;style&gt;<br>BODY {<br> font-family : Arial, Helvetica, sans-serif;<br> font-size : smaller;<br> font-style : normal;<br> font-weight : normal;<br> color : Navy;<br>}<br>&lt;/style&gt;<br>&lt;/head&gt;<br><br>&lt;body&gt;<br>&lt;form action=&quot;intranet.cfm&quot; method=&quot;POST&quot;&gt;<br>Please Type in Your User Name:<br>&lt;input type=&quot;Text&quot; name=&quot;UserID&quot; value=&quot;UserID&quot; required=&quot;Yes&quot; size=&quot;35&quot; maxlength=&quot;50&quot; tabindex=&quot;1&quot;&gt;&lt;br&gt;&lt;br&gt;<br>Please Type in Your Password:<br>&lt;input type=&quot;Password&quot; name=&quot;Password&quot; value=&quot;Password&quot; align=&quot;LEFT&quot; size=&quot;15&quot; maxlength=&quot;25&quot; tabindex=&quot;2&quot;&gt;&lt;br&gt;&lt;br&gt;<br>&lt;input type=&quot;submit&quot; name=&quot;Submit&quot; id=&quot;Submit&quot; value=&quot;Enter our Secured Site&quot;&gt;<br>&lt;/form&gt;<br><br>&lt;/body&gt;<br>&lt;/html&gt;<br><br>the CF file looks like:<br><br>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;&gt;<br>&lt;cfquery name=&quot;Check&quot; datasource=&quot;user&quot; dbtype=&quot;ODBC&quot;&gt;<br>SELECT * <br>FROM Users<br>WHERE User='#form.UserID#' <br>AND Pass='#form.Password#'<br>&nbsp;&lt;/cfquery&gt;<br>&lt;html&gt;<br>&lt;head&gt;<br> &lt;title&gt;Intranet Welcome Page&lt;/title&gt;<br>&lt;style&gt;<br>BODY {<br> font-family : Arial, Helvetica, sans-serif;<br> font-size : smaller;<br> font-style : normal;<br> font-weight : normal;<br> color : Navy;<br>}<br>&lt;/style&gt;<br>&lt;/head&gt;<br><br>&lt;body&gt;<br>&lt;cfif Check.RecordCount&gt;<br>&lt;cfset session.authenticated=1&gt;<br>&lt;cflocation url=&quot;intranet.cfm&quot; addtoken=&quot;yes&quot;&gt;<br>&lt;h2&gt;Welcome to our Intranet&lt;/h2&gt;<br>Please click on the button below to enter the intranet site.&lt;br&gt;&lt;br&gt;<br>&lt;a href=&quot;Intranet.html&quot;&gt;<br>&lt;img src=&quot;Intranet Home.gif&quot; width=&quot;162&quot; height=&quot;41&quot; alt=&quot;&quot; border=&quot;0&quot;&gt;<br>&lt;/a&gt;<br><br>&lt;cfelse&gt;<br>&lt;h2&gt;You are not an authorized user&lt;/h2&gt;&lt;br&gt;<br>&lt;img src=&quot;assets/images/g0602018.gif&quot; width=&quot;137&quot; height=&quot;146&quot; alt=&quot;&quot; border=&quot;0&quot;&gt;&lt;br&gt;<br>Please click on the link below to be taken to our home page.&nbsp;&nbsp;&lt;br&gt;<br><br>&lt;a href=&quot;<A HREF=" TARGET="_new"> Page&lt;/a&gt;<br>&lt;br&gt;<br>Thank you.<br>&lt;/cfif&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;<br><br>I keep getting the following error even though I have my application.cfm set up which gives user sessions abilities:<br><br>Error Diagnostic Information<br>Error resolving parameter FORM.USERID<br><br>The specified form field cannot be found. This problem is very likely due to the fact that you have misspelled the form field name.<br><br>The error occurred while evaluating the expression: <br><br>#form.UserID#<br><br>The error occurred while processing an element with a general identifier of (#form.UserID#), occupying document position (5:13) to (5:25). <br><br>Date/Time: 06/21/00 15:34:07<br>Browser: Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt)<br>Remote Address: 127.0.0.1<br>HTTP Referer: <A HREF=" TARGET="_new"> C:\WebSite\htdocs\intranet.cfm<br><br>I understand what the error means but why would I continue to get it when the form is passing UserID over to the file.<br><br>Any help would be appreciated.
 
I did that the database fields are user and pass and the html form is passing the variables UserID and Password for verification but it's still not working.<br><br>Any other ideas - anyone?
 
just pass u'r fields as url parameter<br><br>&nbsp;like this&nbsp;&nbsp;<br><br>&lt;cflocation url = &quot;filecfm.cfm?username=#username#<br><br><br>i think it helps<br><br><br><br>
 
Maybe, you don't need write&nbsp;&nbsp;&nbsp;&quot;form.UserId&quot;<br>it's better if you define un parameter <br><br>&lt;cfparam&nbsp;&nbsp;name=&quot;UserId&quot; default=&quot;&quot;&gt;<br>&lt;cfparam&nbsp;&nbsp;name=&quot;Password&quot; default=&quot;&quot;&gt;<br>and then write<br>&lt;cfquery name=&quot;Check&quot; datasource=&quot;user&quot; dbtype=&quot;ODBC&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SELECT * <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FROM Users<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;WHERE User=#UserID#<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AND Pass=#Password#<br>&lt;/cfquery&gt;<br><br>I think, it'll help you...
 
Maybe, you don't need write&nbsp;&nbsp;&nbsp;&quot;form.UserId&quot;<br>it's better if you write:<br><br>&lt;cfparam&nbsp;&nbsp;name=&quot;UserId&quot; default=&quot;&quot;&gt;<br>&lt;cfparam&nbsp;&nbsp;name=&quot;Password&quot; default=&quot;&quot;&gt;<br><br>&lt;cfquery name=&quot;Check&quot; datasource=&quot;user&quot; dbtype=&quot;ODBC&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SELECT * <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FROM Users<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;WHERE User=#UserID#<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AND Pass=#Password#<br>&lt;/cfquery&gt;<br><br>I think, it'll help you...
 
The REAL problem here is the line:<br>&lt;cflocation url=&quot;intranet.cfm&quot; addtoken=&quot;yes&quot;&gt;<br><br>Ok, follow me through here now...<br>1. The user enters his name & pwd on the first form, hits the Submit button, and the UserID and Password fields are submitted to intranet.cfm, which I assume is your second form.<br><br>2. The Check query at the top of intranet.cfm runs just fine, and processing continues down to the &lt;cflocation url=&quot;intranet.cfm&quot; addtoken=&quot;yes&quot;&gt; tag.<br><br>3. The cflocation tag is essentially a GOTO.&nbsp;&nbsp;CF stops processing the current page, flushes all form and url variables, then starts processing the page specified in the cflocation tag.<br><br>4. The cflocation tag specifies the same page as is currently running.&nbsp;&nbsp;(Why are you doing this? it makes no sense to me?)<br><br>5. CF starts processing intranet.cfm the second time, but THIS time without the form variables, and so the error occurs.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top