CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 Making an error not show up on Login page ... need help fast!

Print topic Send  topic

Author Message
zylstrahd

Posts: 6
Posted: 04/04/2005, 7:38 AM

Under the Login_events.asp page, here is what I have:


<%
'BindEvents Method @1-3261B678
Sub BindEvents()
Set Login.Button_DoLogin.CCSEvents("OnClick") = GetRef("Login_Button_DoLogin_OnClick")
End Sub
'End BindEvents Method

Function Login_Button_DoLogin_OnClick() 'Login_Button_DoLogin_OnClick @3-ADB4691A

'Login @4-AA430BB1
With Login
If NOT CCLoginUser(.login.Value, .password.Value) Then
.Errors.addError("Login or Password is incorrect.")
Login_Button_DoLogin_OnClick = False
.password.Value = ""
Else
If Not IsEmpty(CCGetParam("ret_link", Empty)) Then _
Redirect = CCGetParam("ret_link", Empty)
Login_Button_DoLogin_OnClick = True
End If
End With
'End Login

'Custom Code @9-73254650

Dim DBcompany

Set DBcompany = New clsDBcompany
DBcompany.Open

Session("LocID") = CCDLookup("location_id","employees","emp_id=" & CCGetUserID(), DBcompany)
Session("LoginID") = CCDLookup("emp_login","employees","emp_id=" & CCGetUserID(), DBcompany)

DBcompany.Close

Response.Cookies("Userlogin")= Login.login.Value
Response.Cookies("Userpass")= Login.password.Value

If Session("GroupID") = 1 Or Session("GroupID") = 3 Then
Redirect="saleslog_list.asp"
End If

'End Custom Code

End Function 'Close Login_Button_DoLogin_OnClick @3-54C34B28

%>



Everytime when someone enters their login information incorrectly, they get the error "Login or Password is incorrect." Also, they get this error:


Source: CCDLookUp function
Command Text: SELECT location_id FROM employees WHERE emp_id=
Error description: Syntax error (missing operator) in query expression 'emp_id='. (Microsoft JET Database Engine)<br>


Source: CCDLookUp function
Command Text: SELECT emp_login FROM employees WHERE emp_id=
Error description: Syntax error (missing operator) in query expression 'emp_id='. (Microsoft JET Database Engine)<br>



I know that the code in the Custom Code section is causing this error. How do I make it so that error doesn't show up when someone enters their login information incorrectly? :(
View profile  Send private message
peterr


Posts: 5971
Posted: 04/04/2005, 8:07 AM

It is usually not a good idea to hide errors instead of fixing them...
I think that you should simply not execute your code if the user is not logged in and UserID is empty.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
zylstrahd

Posts: 6
Posted: 04/05/2005, 7:39 AM

Quote peterr:
It is usually not a good idea to hide errors instead of fixing them...
I think that you should simply not execute your code if the user is not logged in and UserID is empty.
The error that comes up, "Login or Password is incorrect," is perfectly fine. That's what I want. It's just that the other error I get, the CCDLookUp syntax error, is annoying. I know that the custom code is causing that error. So how do I make it so that it doesn't show up? Where should I put the custom code?
View profile  Send private message
peterr


Posts: 5971
Posted: 04/05/2005, 11:33 PM

"Login or Password is incorrect" is not an error, just a message for the user.
But it is usually not a good idea to hide program errors instead of fixing them... Thus I think that you should fix it instead of "not show up".
To fix an error you'd need to modify your code as I wrote above: "simply not execute your code if the user is not logged in and UserID is empty."
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
zylstrahd

Posts: 6
Posted: 04/06/2005, 6:48 AM

Quote peterr:
To fix an error you'd need to modify your code as I wrote above: "simply not execute your code if the user is not logged in and UserID is empty."
How do I do that? I've tried everything.
View profile  Send private message
zylstrahd

Posts: 6
Posted: 04/06/2005, 7:17 AM

Never mind, I just figured it out!

I never thought of this before; all I did was moved a section of the custom code (where I establish a connection to the database, set the session variables LocID and LoginID, and close the connection) into the Else part of the Login_Button_DoLogin_OnClick() function. So now my code looks like this:


<%
'BindEvents Method @1-3261B678
Sub BindEvents()
Set Login.Button_DoLogin.CCSEvents("OnClick") = GetRef("Login_Button_DoLogin_OnClick")
End Sub
'End BindEvents Method

Function Login_Button_DoLogin_OnClick() 'Login_Button_DoLogin_OnClick @3-ADB4691A

'Login @4-AA430BB1
With Login
If NOT CCLoginUser(.login.Value, .password.Value) Then
.Errors.addError("Login or Password is incorrect.")
Login_Button_DoLogin_OnClick = False
.password.Value = ""
Else
If Not IsEmpty(CCGetParam("ret_link", Empty)) Then _
Redirect = CCGetParam("ret_link", Empty)
Login_Button_DoLogin_OnClick = True

Dim DBcompany

Set DBcompany = New clsDBcompany
DBcompany.Open

Session("LocID") = CCDLookup("location_id","employees","emp_id=" & CCGetUserID(), DBcompany)
Session("LoginID") = CCDLookup("emp_login","employees","emp_id=" & CCGetUserID(), DBcompany)

DBcompany.Close

End If
End With
'End Login

'Custom Code @9-73254650

Response.Cookies("Userlogin")= Login.login.Value
Response.Cookies("Userpass")= Login.password.Value

If Session("GroupID") = 1 Or Session("GroupID") = 3 Then
Redirect="saleslog_list.asp"
End If

'End Custom Code

End Function 'Close Login_Button_DoLogin_OnClick @3-54C34B28

%>



Now I don't get the CCDLookup errors. I'm so happy! :-)
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.