Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. how to do Login..?

how to do Login..?

Scheduled Pinned Locked Moved ASP.NET
databasetutorialquestion
7 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    chubbie
    wrote on last edited by
    #1

    hmm.. here's the situation: i have an aspx page (Login purposes).. have 2 textboxes (ID= IdTextBox and PassTextBox) have a button (Login, ID= LoginBtn).. i have a database>table for this section (Table name= Registration) what i intend to do is, when user (either administrator or guest) key in the user id and the password and click the Login Button, the textboxes will compare with the database, see whether the login id and password is registerd or not.. (Validate) the thing is, i dunno what to type inside the Page_Load and LoginBtn_Clicked.. any one willing to type out the code for me..? as i am poOr in coding.. thanks..:) -DarkangeL-

    P C I 3 Replies Last reply
    0
    • C chubbie

      hmm.. here's the situation: i have an aspx page (Login purposes).. have 2 textboxes (ID= IdTextBox and PassTextBox) have a button (Login, ID= LoginBtn).. i have a database>table for this section (Table name= Registration) what i intend to do is, when user (either administrator or guest) key in the user id and the password and click the Login Button, the textboxes will compare with the database, see whether the login id and password is registerd or not.. (Validate) the thing is, i dunno what to type inside the Page_Load and LoginBtn_Clicked.. any one willing to type out the code for me..? as i am poOr in coding.. thanks..:) -DarkangeL-

      P Offline
      P Offline
      PrakashBhaskar
      wrote on last edited by
      #2

      Hi, Try with this following code and you have to use the using System.Data.SqlClient name space. private SqlConnection Conn; private SqlCommand Cmd; public DataSet ds; int id string psswd; id = Convert.ToInt32(TextBox1.Text.ToString().Trim()); psswd = TextBox1.Text.ToString().Trim(); Conn = new SqlConnection("Initial Catalog=BugTracker; Data Source=servername;UID=userid;PWD=password"); Conn.Open(); ds = new DataSet(); SqlDataAdapter adpt = new SqlDataAdapter("SELECT * FROM tablename where id = "+id+"psswd = "+psswd,Conn); adpt.Fill(ds, "table name"); if(ds.Tables[0].Rows.Count > 0) { -- statement -- } Thanks Warm Regards Prakash-B

      C E C 3 Replies Last reply
      0
      • P PrakashBhaskar

        Hi, Try with this following code and you have to use the using System.Data.SqlClient name space. private SqlConnection Conn; private SqlCommand Cmd; public DataSet ds; int id string psswd; id = Convert.ToInt32(TextBox1.Text.ToString().Trim()); psswd = TextBox1.Text.ToString().Trim(); Conn = new SqlConnection("Initial Catalog=BugTracker; Data Source=servername;UID=userid;PWD=password"); Conn.Open(); ds = new DataSet(); SqlDataAdapter adpt = new SqlDataAdapter("SELECT * FROM tablename where id = "+id+"psswd = "+psswd,Conn); adpt.Fill(ds, "table name"); if(ds.Tables[0].Rows.Count > 0) { -- statement -- } Thanks Warm Regards Prakash-B

        C Offline
        C Offline
        Colin Angus Mackay
        wrote on last edited by
        #3

        PrakashBhaskar wrote:

        TextBox1.Text.ToString().Trim()

        The ToString() is reduntant. The return value from the Text property is already a string.

        PrakashBhaskar wrote:

        new SqlDataAdapter("SELECT * FROM tablename where id = "+id+"psswd = "+psswd,Conn);

        Jeez - For something as important as logging in (a security issue) your code is vulnerable to attack. If I type in to the password text box something like

        ' AND 1=1;--

        then I'll log in regardless. Actually - that assumed that your SQL Statement was actually formed in the first place. I would suggest that you read about SQL Injection Attacks and how to prevent them[^] ColinMackay.net "Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius "If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell

        1 Reply Last reply
        0
        • C chubbie

          hmm.. here's the situation: i have an aspx page (Login purposes).. have 2 textboxes (ID= IdTextBox and PassTextBox) have a button (Login, ID= LoginBtn).. i have a database>table for this section (Table name= Registration) what i intend to do is, when user (either administrator or guest) key in the user id and the password and click the Login Button, the textboxes will compare with the database, see whether the login id and password is registerd or not.. (Validate) the thing is, i dunno what to type inside the Page_Load and LoginBtn_Clicked.. any one willing to type out the code for me..? as i am poOr in coding.. thanks..:) -DarkangeL-

          C Offline
          C Offline
          Colin Angus Mackay
          wrote on last edited by
          #4

          The article you are looking for is: Building Secure ASP.NET Applications: Authentication, Authorization, and Secure Communication: How To: Use Forms Authentication with SQL Server 2000[^] ColinMackay.net "Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius "If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell

          1 Reply Last reply
          0
          • P PrakashBhaskar

            Hi, Try with this following code and you have to use the using System.Data.SqlClient name space. private SqlConnection Conn; private SqlCommand Cmd; public DataSet ds; int id string psswd; id = Convert.ToInt32(TextBox1.Text.ToString().Trim()); psswd = TextBox1.Text.ToString().Trim(); Conn = new SqlConnection("Initial Catalog=BugTracker; Data Source=servername;UID=userid;PWD=password"); Conn.Open(); ds = new DataSet(); SqlDataAdapter adpt = new SqlDataAdapter("SELECT * FROM tablename where id = "+id+"psswd = "+psswd,Conn); adpt.Fill(ds, "table name"); if(ds.Tables[0].Rows.Count > 0) { -- statement -- } Thanks Warm Regards Prakash-B

            E Offline
            E Offline
            enjoycrack
            wrote on last edited by
            #5

            Yep, you can base on this idea but using parameterized query... << >>

            1 Reply Last reply
            0
            • C chubbie

              hmm.. here's the situation: i have an aspx page (Login purposes).. have 2 textboxes (ID= IdTextBox and PassTextBox) have a button (Login, ID= LoginBtn).. i have a database>table for this section (Table name= Registration) what i intend to do is, when user (either administrator or guest) key in the user id and the password and click the Login Button, the textboxes will compare with the database, see whether the login id and password is registerd or not.. (Validate) the thing is, i dunno what to type inside the Page_Load and LoginBtn_Clicked.. any one willing to type out the code for me..? as i am poOr in coding.. thanks..:) -DarkangeL-

              I Offline
              I Offline
              Ista
              wrote on last edited by
              #6

              Create a UserClass. \ Create a stored procedure that return the UserID Have the User class call its own procedure with the ID like "usp_GetUser". Populate off the properties of the user. Store the user class inside the session. Nick 1 line of code equals many bugs. So don't write any!!

              1 Reply Last reply
              0
              • P PrakashBhaskar

                Hi, Try with this following code and you have to use the using System.Data.SqlClient name space. private SqlConnection Conn; private SqlCommand Cmd; public DataSet ds; int id string psswd; id = Convert.ToInt32(TextBox1.Text.ToString().Trim()); psswd = TextBox1.Text.ToString().Trim(); Conn = new SqlConnection("Initial Catalog=BugTracker; Data Source=servername;UID=userid;PWD=password"); Conn.Open(); ds = new DataSet(); SqlDataAdapter adpt = new SqlDataAdapter("SELECT * FROM tablename where id = "+id+"psswd = "+psswd,Conn); adpt.Fill(ds, "table name"); if(ds.Tables[0].Rows.Count > 0) { -- statement -- } Thanks Warm Regards Prakash-B

                C Offline
                C Offline
                chubbie
                wrote on last edited by
                #7

                hmm.. just to clarify something.. where shall i type these codes in..? under which section etc... -DarkangeL-

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups