Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- The C# for the login
- protected void ButtonLogin_Click(object sender, EventArgs e)
- {
- {
- SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["wedire"].ConnectionString);
- conn.Open();
- string checkuser = "select count (*) from table_wedire where UserName = '" + TextBoxUname.Text + "'";
- SqlCommand com = new SqlCommand(checkuser, conn);
- int temp = Convert.ToInt32(com.ExecuteScalar().ToString());
- conn.Close();
- if (temp == 1)
- {
- conn.Open();
- string checkPasswordQuery = "select UserPass from table_wedire where UserName = '" + TextBoxUname.Text + "'";
- SqlCommand passComm = new SqlCommand(checkPasswordQuery, conn);
- string password = passComm.ExecuteScalar().ToString().Replace(" ", "");
- if (password == TextBoxPass.Text)
- {
- Session["New"] = TextBoxUname.Text;
- Response.Write("Password is correct.");
- Response.Redirect("adminpage.aspx");
- }
- else
- {
- Response.Write("Password is not correct.");
- }
- }
- else
- {
- Response.Write("Username is not correct.");
- conn.Close();
- }
- }
- }
- The Web.config file stuff for authorization
- <location path="adminpage.aspx">
- <system.web>
- <authorization>
- <allow users="wedire" />
- <deny users="*" />
- </authorization>
- </system.web>
- </location>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement