I'm creating a website using asp.net. So far, I have a registration page finished which saves details to a database table.
How would I check if a username and password is in that table, then allow them to proceed to the next page?
Here is my code for registration;
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["userinfo.ConnectionString"].ConnectionString);
conn.Open();
string insertQuery = "INSERT INTO [user] (UserName, FirstName, LastName, Email, Password, Country) VALUES (@uname, @fname, @lname, @email, @password, @country)";
SqlCommand comm = new SqlCommand(insertQuery, conn);
comm.Parameters.AddWithValue("@uname", usernametextbox.Text);
comm.Parameters.AddWithValue("@fname", fnametextbox.Text);
comm.Parameters.AddWithValue("@lname", lnametextbox.Text);
comm.Parameters.AddWithValue("@email", emailtextbox.Text);
comm.Parameters.AddWithValue("@country", DropDownListcountry.Text);
comm.Parameters.AddWithValue("@password", passwordtextbox.Text);
comm.ExecuteNonQuery();
conn.Close();
I'm guessing I'd need to create a SELECT query, with an if-statement maybe?