Click here to Skip to main content
15,884,943 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to enter either email_id or user_name from one textbox

i am using this query but it is taking only first field from query i.e. email_id it is failed for user_name

C#
string str = "select login_with_email from PROFILE where  email_id='" + txt_login_userid.Text.Trim() + "' OR user_name ='" + txt_login_userid.Text.Trim() + "' and password= ' " + txt_login_pass.Text.Trim()+'" " ;


[edit]code block added[/edit]
Posted
Updated 16-Nov-12 23:04pm
v2
Comments
faisal23 17-Nov-12 4:36am    
Provide one check box on login page chech if login through email then it is simply solved.
Member 9579525 17-Nov-12 4:44am    
i m trying following way..
on registration form user have to choose the way how to login ie. either email id or user name
faisal23 17-Nov-12 4:53am    
ok so make stored procedure or in above query pass only one parameter for email or name based on selection and check in query if user use email then in query compare with email and same as for name.

1 solution

Just add () right now you are checking if user have given email OR (have login and password), so right now when you enter email and password correctly system will not permit you to login.

C#
string str = "select login_with_email from PROFILE where (email_id='" + txt_login_userid.Text.Trim() + "' OR user_name ='" + txt_login_userid.Text.Trim() + "') and password= ' " + txt_login_pass.Text.Trim()+'" " ; 

But seriously I don't want to start pointing how many things is wrong with this. Use sql parameters at least.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900