Пример #1
0
        protected void signupbtn_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Debug.WriteLine("pressed");
            SessionsTbl values = new SessionsTbl()
            {
                name     = inputname.Text,
                age      = int.Parse(inputage.Text),
                email    = inputemail.Text,
                password = inputpassword.Text
            };

            DBConnectivity connectivity = new DBConnectivity();
            bool           response     = connectivity.insertRecord(values);

            System.Diagnostics.Debug.WriteLine("added");



            if (response)
            {
                Session["email"] = values.email;
                Session["name"]  = values.name;
                Response.Redirect("~/Dashboard.aspx");
            }
        }
Пример #2
0
        public SessionsTbl getOneRecord(string email)
        {
            SqlConnection conn = makeConnection();

            conn.Open();

            string     query = "select * from sessions_tbl where email = '" + email + "'";
            SqlCommand cmd   = new SqlCommand(query, conn);

            SqlDataReader reader = cmd.ExecuteReader();

            SessionsTbl valuesFromDb = new SessionsTbl();

            if (reader.Read())
            {
                valuesFromDb.id       = int.Parse(reader["id"].ToString());
                valuesFromDb.name     = reader["name"].ToString();
                valuesFromDb.age      = int.Parse(reader["age"].ToString());
                valuesFromDb.email    = reader["email"].ToString();
                valuesFromDb.password = reader["password"].ToString();
            }

            conn.Close();
            return(valuesFromDb);
        }
Пример #3
0
        protected void loginbtn_Click(object sender, EventArgs e)
        {
            string         email        = inputemail.Text;
            string         password     = inputpassword.Text;
            DBConnectivity connectivity = new DBConnectivity();
            SessionsTbl    valuesFromDb = connectivity.getOneRecord(email);

            if (valuesFromDb.email.Equals(email) && valuesFromDb.password.Equals(password))
            {
                Session["email"] = valuesFromDb.email;
                Session["name"]  = valuesFromDb.name;
                Response.Redirect("~/Dashboard.aspx");
            }
        }
Пример #4
0
        public bool insertRecord(SessionsTbl values)
        {
            SqlConnection conn = makeConnection();

            conn.Open();
            string query = "insert into sessions_tbl(name, age, email, password) values('" + values.name + "', '" + values.age + "', '" + values.email + "', '" + values.password + "')";

            SqlCommand cmd = new SqlCommand(query, conn);

            int result = cmd.ExecuteNonQuery();

            conn.Close();

            if (result > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }