|
I use this code for my site login script (it's basically -borg-'s code slightly modified)......... The problem is that i got a JavaScript pop up at the end of the code (text in red) and all the code is getting executed but those lines so i don't get no pop up when the password is incorrect. Any ideas why this is happening? here's the code:
'If a username has been entered check that the password is correct If NOT strUsername = "" Then
'Read the various forums from the database 'Initalise the strSQL variable with an SQL statement to query the database strSQL = "SELECT tblAuthor.Password, tblAuthor.Salt, tblAuthor.Author_ID, tblAuthor.User_code " strSQL = strSQL & "FROM tblAuthor " strSQL = strSQL & "WHERE tblAuthor.Username = '" & strUsername & "';"
'Query the database rsCommon.Open strSQL, adoCon
'If the query has returned a value to the recordset then check the password is correct
If NOT rsCommon.EOF Then
'Encrypt password so we can check it against the encypted password in the database 'Read in the salt strPassword = strPassword & rsCommon("Salt")
'Encrypt the entered password strPassword = HashEncode(strPassword)
'Check the encrypted password is correct, if it is get the user ID and set a cookie
If strPassword = rsCommon("Password") Then
'Read in the users ID number and whether they want to be automactically logged in when they return to the forum lngUserID = CLng(rsCommon("Author_ID")) strUserCode = rsCommon("User_code")
'Write a cookie with the User ID number so the user logged in throughout the forum 'Write the cookie with the name Forum containing the value UserID number Response.Cookies("Forum")("UID") = strUserCode If CBool(Request.Form("ActiveUsers")) = False Then Response.Cookies("Forum")("Hide") = True Else Response.Cookies("Forum")("Hide") = False End If
'If the user has selected to be remebered when they next login then set the expiry date for the cookie for 1 year If blnAutoLogin = True Then
'Set the expiry date for 1 year 'If no expiry date is set the cookie is deleted from the users system 20 minutes after they leave the forum Response.Cookies("Forum").Expires = DateAdd("yyyy", 1, Now()) End If
'Reset Server Objects rsCommon.Close Set rsCommon = Nothing adoCon.Close Set adoCon = Nothing Response.Redirect strNewRedir
End If
End If
'Popup alert if username or password is invalid Response.Write("<script language=""JavaScript"">") Response.Write("alert('Invalid Username And/Or Password');") Response.Write("</script>")
End If
------------- FeRnAN
http://www.danasoft.com/">
|