This topic is locked

Informix Login Problems

1/28/2010 04:52:47
ASPRunnerPro General questions
M
MrDerp author

I am currently working on a login page for my ASPRunnerPro project but I am having difficulties due to restrictions with my Informix database.
The version of Informix I am using does not allow the use of the varchar data type, so I am using char instead. However, as char uses a fixed length, when I try to log in using a username and password less than the maximum length of the field, I am having to add whitespace to each field in order to get an exact match against the database.
Is there any way I can add a custom event or change some source code to fix this?
Thanks in anticipation.

J
Jane 1/28/2010

Hi,
use Login page: Before login event to check and change username and password.
Example:



'pad username and password to make them 10 characters long

n=10

username = username & String(n-len(username)," ")

password = password & String(n-len(password)," ")
M
MrDerp author 1/29/2010

Thanks Jane.
That's a partial solution, but I now have to click "Submit" twice. The first time I click it says "invalid login" and pads the fields, and then when I click it again, because it padded the fields previously, it then lets me logon.
Do you know if there is a more seamless way of doing this, so it pads the fields before processing the login event?
Thanks in anticipation.

J
Jane 1/29/2010

What ASPRunnerPro version do you use?

M
MrDerp author 1/29/2010

I am currently using version 6.1.

Sergey Kornilov admin 1/29/2010

My fault. Try the following:

n=10

username = username & String(n-len(username)," ")

password = password & String(n-len(password)," ")

if bValue(NeedQuotes(cUserNameFieldType)) then

username = ("'" & CSmartStr(db_addslashes(username ))) & "'"

else

username = 0+CSmartDbl(username )

end if

if bValue(NeedQuotes(cPasswordFieldType)) then

password = ("'" & CSmartStr(dbaddslashes(password ))) & "'"

else

password = 0+CSmartDbl(password )

end if

strSQL = "select * LoginTableName where " & AddFieldWrappers(cUserNameField) & "=" &


CSmartStr(username) & " and " & AddFieldWrappers(cPasswordField) & "=" & CSmartStr(password)


Replace LoginTableName with the actual login table name.

M
MrDerp author 2/1/2010

I've tried the updated code but I'm having the exact same problem.
There were initially issues with the lines:
username = ("'" & CSmartStr(db_addslashes(username))) & "'"

password = ("'" & CSmartStr(db_addslashes(password))) & "'"
This was adding apostrophes (') to each of the fields, resulting in an error. However, after updating these lines to not add the extra apostrophes, I still have to click submit twice.

M
MrDerp author 2/3/2010

Any ideas?
This is holding me back a bit at the moment, so any help would be greatly appreciated.

Sergey Kornilov admin 2/3/2010

Mr Derp,
according to my understanding the initial problem was related to the way CHAR fields are stored in Informix (padded with spaces to fit the field length). Right now it seems to be the issue with apostrophes.
To avoid the confusion open a ticket at http://support.xlinesoft.com sending your order number, code you adding and error message you getting (or problem description).

M
MrDerp author 2/5/2010

I managed to resolve this issue my adding the following lines to login.asp:



n = 30

pUsername = pUsername & String(n-len(pUsername)," ")

pPassword = pPassword & String(n-len(pPassword)," ")