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!

Adding new user problem

Status
Not open for further replies.

calista

Programmer
Jan 24, 2001
545
US
Here's the situation. I just updated my intranet to use cookies, and everything's fine except for one thing. If validation fails during new user registration, they are kicked back to the login screen, instead of being redirected back to the registration form with their valid info filled in.

I have Application.cfm checking for the existance of a cookie or a session variable. If it doesn't find either one, it presents the login screen. On the login screen, I have two links, one to ForgotPassword.cfm, and the other is to AddNewPerson.cfm, which is the form page. The action page is AddUserValidate.cfm. Now, before Application.cfm sends the login screen, it checks to see what page the user is trying to access. If it is one of the three I have listed above, it goes right to it without the login screen.

When I validate the registration data, I use CFLOCATION to send them back to AddNewPerson.cfm and pass back all the information. If validation is successful, all is well, but if validation fails, they get the login screen instead of AddNewPerson.cfm. In other words, if they link to AddNewPerson.cfm, it works, if they are redirected with CFLOCATION, it doesn't.

How can I direct them back to the form page? I already made that page an exception to requiring logging in. Thanks! Calista :-X
Jedi Knight,
Champion of the Force
 
you should post the relevant part of you application.cfm here - it would help to spot the flaw !
 
Sorry, here it is:

Application.cfm
Code:
<CFSET ThisPage = &quot;#getFileFromPath(cgi.script_name)##cgi.query_string#&quot;>
<CFSET ThisFlag = &quot;No&quot;>

<CFIF #ThisPage# EQ &quot;ForgotPassword.cfm&quot; OR #ThisPage# EQ &quot;AddNewPerson.cfm&quot; OR #ThisPage# EQ &quot;AddUserValidate.cfm&quot;>
	<CFSET ThisFlag = &quot;Yes&quot;>
</CFIF>

<CFIF ThisFlag EQ &quot;No&quot;>
	<CFINCLUDE TEMPLATE=&quot;CommonFiles/GateKeeper.cfm&quot;>
</CFIF>
Calista :-X
Jedi Knight,
Champion of the Force
 
-> in app.cfm, you wrote &quot;if the user trys to reach ForgotPassword.cfm OR AddNewPerson.cfm OR AddUserValidate.cfm then DONT CHECK&quot;
-> so &quot;If it is one of the three I have listed above, it goes right to it without the login screen.&quot; is a totally normal behaviour !
 
The problem is, it only works through the links. If a new user is trying to register, and it fails validation, it kicks him out to the login screen. What I am trying to do is send him back to AddNewPerson.cfm if validation fails. Here is some code from AddUserValidate.cfm:
Code:
<CFIF ERRORFLAG IS &quot;Yes&quot;>
			<CFLOCATION URL=&quot;AddNewPerson.cfm?FirstName=#Form.FirstName#&LastName=#Form.LastName#&Password=#Form.Password#&Email=#Form.Email#&Phone=#Form.Phone#&Submit=Yes&quot;>
		</CFIF>
I do the error checking, and if anything is wrong, I set ErrorFlag to &quot;yes&quot;, and, as you can see, I redirect the user back to the form page along with the variables. This is where the user gets sent to the login screen instead of the form page. Calista :-X
Jedi Knight,
Champion of the Force
 
A couple of things maybe I should clarify.

1) When validation fails, the user is kicked out to the login screen, he is not in the database so he cannot login. Plus, the user has no idea why he cannot register.

2) If validation is successful, the cookie and session variables are set, and the user is taken directly to the Home page. Calista :-X
Jedi Knight,
Champion of the Force
 
Hey Calista,

I think I see the problem. When you set &quot;thisPage&quot;, you're setting it to the script name plus the query_String information. Thus, #thisPage# equals &quot;AddNewPerson.cfm&quot; when they click a link to it and &quot;AddNewPerson.cfmFirstName=John...&quot; when they are re-directed. Since your comparison is checking an exact string match, it will fail when the extra query string info is present. I would either set #thisPage# to just the script name or modify your comparison to this:

OR left(ThisPage,16) EQ &quot;AddNewPerson.cfm&quot;

Hope this helps,
GJ
 
Thanks, GJ, I had noticed that. I found I had the same problem if the user tried again and validation failed a second time. I can't imagine these people doing that, but you never know. Almost all of my users are engineers of one kind or another, so they're pretty smart folks.

I went with setting &quot;ThisPage&quot; to #CGI.SCRIPT_NAME#, so that should take care of it. Calista :-X
Jedi Knight,
Champion of the Force
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top