Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected void Page_Load(object sender, EventArgs e)
- {
- this.cmd = Convert.ToInt16(Request["cmd"]);
- this.username = Request["username"].ToString();
- this.password = Request["password"].ToString();
- switch (cmd)
- {
- case 1:
- string res = IsUser();
- Response.Redirect(res);
- break;
- }
- }
- public string IsUser()
- {
- string resultat="";
- SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=D:\Gabriel\Documents\Teccart\session_4\ASP\dating\dating\App_Data\datingBd.mdf;Integrated Security=True");
- con.Open();
- SqlCommand isuser = new SqlCommand("select * from users where username = @u and password = @p;",con);
- //SqlCommand isuser = new SqlCommand("select * from users where username=@u;",con);
- isuser.Parameters.AddWithValue("@u", username);
- isuser.Parameters.AddWithValue("@p", password);
- SqlDataReader reader = isuser.ExecuteReader();
- while (reader.Read())
- {
- if (reader.HasRows)
- {
- resultat = "1";
- }
- else
- {
- resultat = "0";
- }
- }
- return resultat;
- con.Close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement