예제 #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["Email"] != null)
     {
         email = Session["Email"].ToString();
         name  = connectdata.getUserName(email);
         string id = new connectdata().getUserId(email);
         points = connectdata.getUserPoints(id);
     }
 }
예제 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["signup"] != null)
            {
                string name     = Request.Form["create-fullname"];
                string email    = Request.Form["create-email"];
                string password = Request.Form["create-password"];
                string contact  = Request.Form["create-contact"];
                string aboutyou = Request.Form["create-aboutyou"];
                string interest = Request.Form["create-interest"];
                string birthday = Request.Form["create-birthday"];

                bool isEmailExist = new connectdata().isEmailExists(email);
                if (!isEmailExist)
                {
                    string hashpass = connectdata.HashPass(password);
                    String query    = "INSERT INTO Users (Name, Email, Password, Contact, Usertype, about_me, interest, birthday) VALUES ('" + name + "','" + email + "','" + hashpass + "','" + contact + "','Student','" + aboutyou + "','" + interest + "','" + birthday + "')";
                    connectdata.executeQuery(query);
                    Response.Redirect("LoginSignup.aspx?signupsucces=true");
                }
                else
                {
                    Response.Write("<script>alert('Email already exists!');</script");
                }
            }

            if (Request.QueryString["signupsucces"] != null)
            {
                Response.Write("<script>alert('Register successful');</script");
            }

            if (Request.QueryString["login"] != null)
            {
                String username = Request.Form["login-email"];
                String password = Request.Form["login-password"];
                bool   result   = new connectdata().Login(username, password);
                if (result == true)
                {
                    String Usertype = Session["Usertype"].ToString();
                    if (Usertype.Equals("Student"))
                    {
                        Response.Redirect("Index.aspx");
                    }
                    if (Usertype.Equals("Admin"))
                    {
                        Response.Redirect("AdminHome.aspx");
                    }
                }
                else
                {
                    Response.Write("<script>alert('Login failed, incorrect username or password');</script");
                }
            }
        }
예제 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["Email"] != null)
            {
                string email  = Session["Email"].ToString();
                string userid = new connectdata().getUserId(email);
                points = connectdata.getUserPoints(userid);
                String        query = "SELECT * FROM Users WHERE Id=" + userid + "";
                SqlConnection conn  = connectdata.getConnection();
                conn.Open();
                SqlCommand cm = new SqlCommand(query, conn);
                sdr = cm.ExecuteReader();

                if (Request.QueryString["editprofile"] != null)
                {
                    string name     = Request.Form["edit-name"];
                    string contact  = Request.Form["edit-contact"];
                    string aboutyou = Request.Form["edit-aboutyou"];
                    string interest = Request.Form["edit-interest"];
                    string birthday = Request.Form["edit-birthday"];

                    string queryedit = "UPDATE Users SET Name='" + name + "',Contact='" + contact + "',about_me='" + aboutyou + "',interest='" + interest + "',birthday='" + birthday + "'";
                    connectdata.executeQuery(queryedit);
                    Response.Write("<script>alert('edit successful')</script>");
                }
                if (Request.QueryString["changepassword"] != null)
                {
                    string oldpass   = Request.Form["change-oldpass"];
                    string newpass   = Request.Form["change-newpass"];
                    bool   checkpass = connectdata.isPasswordMatch(email, oldpass);
                    string queryedit = "";
                    if (checkpass)
                    {
                        connectdata.executeQuery(queryedit);
                        Response.Write("<script>alert('edit successful')</script>");
                    }
                    else
                    {
                        Response.Write("<script>alert('that is not your old password')</script>");
                    }
                }
            }
            else
            {
                Response.Redirect("LoginSignup.aspx");
            }
        }