Let's see if I can explain this one. In members.asp, around line 121, you will see this bit of code:if srchInitial = "1" then
tmpSQL = strMemberTablePrefix & "MEMBERS.M_NAME LIKE '" & SearchName & "%'"
end if
Now, the code that comes before this piece is building the "WHERE" clause of the SQL query. For example:if srchLName = "1" then
if srchFName = "1" or srchUName = "1" then
tmpSql = tmpSql & " OR "
end if
tmpSql = tmpSql & strMemberTablePrefix & "MEMBERS.M_LASTNAME LIKE '%" & SearchName & "%' "
end if
Now if you notice, the SQL query is being built by adding to the value that is already in the variable tmpSql. But if you look at the first code I posted:tmpSQL = strMemberTablePrefix & "MEMBERS.M_NAME LIKE '" & SearchName & "%'"
it doesn't add to the tmpSql variable, it replaces everything that is stored in it, searching for only the 'M_NAME'.
I would think that the srchInitial variable will not be set to 1, when the user is searching by Username, FirstName or by LastName using the form. srchInitial is set to 1 when the user clicks on one of the lettered links to search for a username starting with that letter. If you use the form to search for a username, firstname or lastname after clicking on of the lettered links, it will always search for the username, since the variable srchInitial was set to 1 and never set to 0 in the code.
For instance, click on one of the lettered links in the members search. Then try doing a search using the form and go button, searching by the lastname or firstname. You will notice it will search just by the username and not by the option you selected.
My suggested fix would be to change this:<input type="hidden" name="initial" value="<%= srchInitial %>">
to this:<input type="hidden" name="initial" value="0">
That sets srchInitial to 0 when using the form to search. srchInitial is only needed when using the lettered links to search for a username.
- David