Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Login Problem

Explorer ,
Jan 06, 2009 Jan 06, 2009
I have a login page where users enter a password which is a combination of the last for digits of their ssn and their 4 digit birth year. for example (43211971).

I am using this query to make the check:

<cfquery name="validatemanager" datasource="SelfNom">
SELECT * FROM tblEmployeeList3
WHERE EmployeeNo = #Form.HREmpNo#
AND right(SSNLast4, 4) = left(#form.HRSSNo#, 4)
AND BirthYear = Right(#form.HRSSNo#, 4)
</cfquery>

My problem is when someone has a last 4 digit ssn that begins with a 0 or two, the query fails the the user gets flagged with an invalid password.

How do I account for missing 0's when they arise?
714
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 06, 2009 Jan 06, 2009
What is the datatype of the ssnlast4 field?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 06, 2009 Jan 06, 2009
Number

the database is Access
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jan 06, 2009 Jan 06, 2009
> Number
> the database is Access

Numeric fields do not not maintain leading zeroes. The different data types also vary in terms of the maximum number they can store.

> I have a login page where users enter a password which is a combination of the last for digits
> of their ssn and their 4 digit birth year. for example (43211971).

I would not stored that kind of information in Access, let alone use it for passwords ... for obvious reasons.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 06, 2009 Jan 06, 2009
although I agree, it is unfortunately not my call. Access is the DB that has been dropped in my lap, and I don not have control over setting up the field types, I am just expected to manipulate the data.

Should I assume there is no solution for this?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jan 06, 2009 Jan 06, 2009
> Should I assume there is no solution for this?

No. You just need to change the column data. Like I said, numeric columns do not allow leading zeroes. So when you insert a value with a leading zero it gets dropped. To preserve the zeroes you have to use a character type like varchar (I believe it is called "text" in Access.)
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jan 06, 2009 Jan 06, 2009
> I don not have control over setting up the field types

I missed that comment. Are you are saying you absolutely cannot change the column type? If you really cannot, you might be able to check the length of the value. If it is 7 (not 8) then assume it has a leading zero. It is very "hack-ish" but may work if you cannot control the field types.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 06, 2009 Jan 06, 2009
I am trying that now, here is the issue I am running into. If the length is 7, what do I do then in the query? I am not sure what that code looks like. How do I manually add a 0 a that point.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jan 06, 2009 Jan 06, 2009
> AND right(SSNLast4, 4) = left(#form.HRSSNo#, 4)
> AND BirthYear = Right(#form.HRSSNo#, 4)

If the SSNLast4 column only stores the last four digits, as the name implies, just append a '0' to that value. Since you are using right(column, 4) the leading zero will ignored if it is not needed.

As an aside, you should also use cfqueryparam for all of the values.





Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 06, 2009 Jan 06, 2009
I'm missing something. Probably because I don't work with Access. If ssnLast4 is a numeric field, how can you perform a right() on it? Isn't right() a string function?

Also, if the last 4 digits of someone's ssn is 0123, what would be the value of the ssnlast4 field for that record?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jan 06, 2009 Jan 06, 2009
> I'm missing something. Probably because I don't work with Access. If ssnLast4 is a numeric field,
> how can you perform a right() on it? Isn't right() a string function?

No, you are probably not missing something. I suspect Access does an automatic conversion from number to string when they call the right() function...
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 07, 2009 Jan 07, 2009
This problem is a mess, it seems that the real issue is that the DB value is a number and should be a text.

Am I correct in this assumption? If the SSN number was a text field, this would not be an issue?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 07, 2009 Jan 07, 2009
Jatrix wrote:
>
> Am I correct in this assumption? If the SSN number was a text field, this
> would not be an issue?
>

You are correct. As a general rule of thumb a database field should
only be a number if you plan or need to do math with it. Just because a
string happens to contain only digits does not mean that a numeric type
field is the best way to store it. For id's such as SSN numbers, phone
numbers, part unit numbers etc, where one is never going to
add|divide|multiply|subtract them then there is no need for them to be
numeric.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 07, 2009 Jan 07, 2009
LATEST
ty
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources