Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- public partial class Login : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- if (Request.Form["submit"] != null)
- {
- string username = Request.Form["userName"];
- string password = Request.Form["password"];
- string Status = "";
- if ((username == null) || (username == "") || (password == "") || (password == null))
- {
- Status = "Fill all the details";
- }
- else
- {
- string filename = "db.mdf";
- string tablename = "siteusers";
- string selectquery = "SELECT * FROM " + tablename + " WHERE userName ='" + Request.Form["userName"] + "'";
- string checkadmin = "SELECT * FROM " + tablename + " WHERE userName ='" + Request.Form["userName"] + "'";
- checkadmin += " AND IsAdmin ='true'";
- string adminquery="SELECT IsAdmin FROM siteusers WHERE userName ='"+Request.Form["userName"]+"'";
- if (MyAdoHelper.IsExist(filename, selectquery) == true)
- {
- selectquery += " AND password ='" + password + "'";
- if (MyAdoHelper.IsExist(filename, selectquery))
- {
- if (MyAdoHelper.IsExist(filename,checkadmin))
- {
- Session["Admin"] = Request.Form["userName"];
- Session["User"] = Request.Form["userName"];
- Status = "Login as admin";
- Response.Write(Status);
- Response.AddHeader("REFRESH", "1;URL=Default.aspx");
- Response.End();
- }
- else
- {
- Session["User"] = Request.Form["userName"];
- Status = "Login Successful";
- Response.Write(Status);
- Response.AddHeader("REFRESH", "1;URL=Default.aspx");
- Response.End();
- }
- }
- else
- {
- Status = "Password is invalid";
- }
- }
- else
- {
- Status="Username is invalid";
- }
- }
- Response.Write(Status);
- Response.AddHeader("REFRESH", "1;URL=Login.aspx");
- Response.End();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement