Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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:33pm
Edited 16-Nov-12 23:04pm
Nelek50.8K
v2
Comments
faisal23 at 17-Nov-12 4:36am
   
Provide one check box on login page chech if login through email then it is simply solved.
Member 9579525 at 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 at 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

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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  
v2

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

  Print Answers RSS
0 CPallini 510
1 Sergey Alexandrovich Kryukov 428
2 George Jonsson 298
3 Pheonyx 218
4 OriginalGriff 200
0 OriginalGriff 4,813
1 CPallini 3,850
2 Sergey Alexandrovich Kryukov 3,224
3 George Jonsson 2,552
4 Gihan Liyanage 2,186


Advertise | Privacy | Mobile
Web03 | 2.8.140905.1 | Last Updated 17 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100