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 23:33pm
Edited 17-Nov-12 0:04am
Nelek60.4K
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 Maciej Los 315
1 OriginalGriff 233
2 Aajmot Sk 224
3 Marcin Kozub 210
4 Richard MacCutchan 200
0 OriginalGriff 7,853
1 Sergey Alexandrovich Kryukov 7,107
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,790


Advertise | Privacy | Mobile
Web02 | 2.8.1411023.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