Click here to Skip to main content
Sign Up to vote bad
good
See more: ASP.NET
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
 
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 16 Nov '12 - 22:33
Edited 16 Nov '12 - 23:04
Nelek26.3K

Comments
faisal23 - 17 Nov '12 - 4:36
Provide one check box on login page chech if login through email then it is simply solved.
Member 9579525 - 17 Nov '12 - 4:44
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:53
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.
 
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.
  Permalink  

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 565
1 Maciej Los 260
2 Slacker007 240
3 OriginalGriff 235
4 Aarti Meswania 175
0 Sergey Alexandrovich Kryukov 9,118
1 OriginalGriff 7,134
2 CPallini 3,803
3 Rohan Leuva 3,135
4 Maciej Los 2,558


Advertise | Privacy | Mobile
Web01 | 2.6.130516.1 | Last Updated 17 Nov 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid