コード例 #1
0
        protected void btnCreatePost_Click(object sender, EventArgs e)
        {
            string   text = txtPost.Text;
            DateTime dt   = DateTime.Now;     //gets current Date and Time from the system

            if (txtPost.Text == String.Empty) //validation to make sure the textbox has been filled in
            {
                lblCreatePostMessage.Text    = "You have not completed one or more required fields";
                lblCreatePostMessage.Visible = true;
                return;
            }

            SQLDatabase.DatabaseTable tPosts = new SQLDatabase.DatabaseTable("Posts");

            SQLDatabase.DatabaseRow row = tPosts.NewRow();

            row.Add("ID", tPosts.GetNextID().ToString());       // adding all the information neccessary to create a post in the db
            row.Add("Text", text);
            row.Add("CreatorID", Session["UserID"].ToString()); //need to make it so it displays the user ID.
            row.Add("CreatorName", Session["Name"].ToString());
            row.Add("BoardID", Session["BoardID"].ToString());  //need to make it so it displays the user ID.
            row.Add("BoardName", Session["BoardName"].ToString());
            row.Add("DateCreated", dt.ToString("dddd, dd MMMM yyyy"));
            row.Add("TimeCreated", dt.ToString("h: mm tt"));

            tPosts.Insert(row);

            Response.Redirect("Boards.aspx"); // takes you back to the boards page after you have created the post
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string boardName = "";

            if (Session["UserID"] == null)
            {
                Response.Redirect("Default.aspx");              // Checks that the user is logged in
            }
            if (Session["UserType"].ToString() != "Admin")      //checks to see if the user is an admin so
                                                                //it knows whether to display the button that goes to Admin page
            {
                btnAdmin.Visible = false;
            }

            SQLDatabase.DatabaseTable boardID = new SQLDatabase.DatabaseTable("Boards", "SELECT * FROM Boards");

            for (int i = 0; i < boardID.RowCount; i++) // loops through the boards db to get the BoardID and store it in a session
            {
                if (boardID.GetRow(i)["ID"] == Session["BoardID"].ToString())
                {
                    boardName = boardID.GetRow(i)["Name"].ToString(); // sets the board name variable to the board name stored in the db
                    break;
                }
            }

            btnBoards.Attributes.Add("onMouseOver", "this.className='hoverbutton'"); // shows pointer when it hovers over the buttons
            btnMyAccount.Attributes.Add("onMouseOver", "this.className='hoverbutton'");
            btnLogout.Attributes.Add("onMouseOver", "this.className='hoverbutton'");
            btnAdmin.Attributes.Add("onMouseOver", "this.className='hoverbutton'");

            lblCurrentBoard.Text = boardName;
        }
コード例 #3
0
        protected void CreatePostButton_Click(object sender, EventArgs e)
        {
            {
                SQLDatabase.DatabaseTable posts_table = new SQLDatabase.DatabaseTable("Posts"); // Need to load the table we're going to insert into.

                SQLDatabase.DatabaseRow new_row = posts_table.NewRow();                         // Create a new based on the format of the rows in this table.

                string new_id       = posts_table.GetNextID().ToString();                       // Use this to create a new ID number for this module. This new ID follows on from the last row's ID number.
                string creatorname  = "1";
                int    creatorid    = int.Parse(creatorname);
                string boardnum     = "1";
                int    boardid      = int.Parse(boardnum);
                string creationdate = "";
                string creationtime = "";

                new_row["ID"]          = new_id;                            // Add some data to the row (using the columns names in the table).
                new_row["Text"]        = CreatePostTextBox.Text.ToString(); // post contents.
                new_row["CreatorID"]   = creatorid.ToString();
                new_row["BoardID"]     = boardid.ToString();
                new_row["DateCreated"] = creationdate;
                new_row["TimeCreated"] = creationtime;

                posts_table.Insert(new_row);                           // Execute the insert - add this new row into the database.
            }
        }
コード例 #4
0
        protected void DataList2_ItemDataBound(object sender, DataListItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                DataListItem i = e.Item;
                //  System.Data.DataRowView r = (System.Data.DataRowView)e.Item.DataItem; // 'r' represents the next row in the table that has been passed here via the 'bind' function.
                System.Data.DataRowView r = Session["Boards"] as DataRowView;;  // 'r' represents the next row in the table that has been passed here via the 'bind' function.


                // Find the label controls that are associated with this data item.

                Label PostsText_LBL    = (Label)e.Item.FindControl("PostsText_Label");           // Find the text Label.
                Label PostsCreator_LBL = (Label)e.Item.FindControl("PostsCreatorID_Label");      // Find the creator ID Label.
                //Label PostsBoardID_LBL = (Label)e.Item.FindControl("PostsBoardID_Label"); // Find the board ID Label.
                Label PostsCreatorName_LBL = (Label)e.Item.FindControl("PostCreatorName_Label"); // Find the creator ID Label.
                Label DateCreated_LBL      = (Label)e.Item.FindControl("Day_Label");             // Find the date created Label.
                Label TimeCreated_LBL      = (Label)e.Item.FindControl("Time_Label");            // Find the date created Label.

                SQLDatabase.DatabaseTable users_table = new SQLDatabase.DatabaseTable("Users", "SELECT Username from Users WHERE ID = " + r["CreatorID"].ToString());
                string Username = users_table.GetRow(0)["Username"];

                PostsText_LBL.Text = r["Text"].ToString();          // Topic name.
                //PostsCreator_LBL.Text = r["CreatorID"].ToString();     // Creator ID number.
                PostsCreatorName_LBL.Text = Username;               // Creator ID number.
                                                                    //PostsBoardID_LBL.Text = r["BoardID"].ToString();     // Board ID number.
                DateCreated_LBL.Text = r["DateCreated"].ToString(); // date created.
                TimeCreated_LBL.Text = r["TimeCreated"].ToString(); // Time created
            }
        }
コード例 #5
0
        protected void btnCreateBoard_Click(object sender, EventArgs e)
        {
            string   subject = txtSubject.Text;
            DateTime dt      = DateTime.Now; //gets current Date and Time from the system

            //Session["BoardName"] = subject; //stores the boardname in a session for later use


            if (txtSubject.Text == String.Empty) // validation for empty textboxes
            {
                lblCreateBoardMessage.Text    = "You have not completed one or more required fields";
                lblCreateBoardMessage.Visible = true;
                return;
            }

            SQLDatabase.DatabaseTable tBoards = new SQLDatabase.DatabaseTable("Boards");

            SQLDatabase.DatabaseRow row = tBoards.NewRow();

            row.Add("ID", tBoards.GetNextID().ToString());      // adds all the info needed to create a new board in the db
            row.Add("Name", subject);
            row.Add("CreatorID", Session["UserID"].ToString()); //need to make it so it displays the user ID.
            row.Add("CreatorName", Session["Name"].ToString());
            row.Add("DateCreated", dt.ToString("dddd, dd MMMM yyyy"));
            row.Add("TimeCreated", dt.ToString("h: mm tt"));

            tBoards.Insert(row);

            Response.Redirect("Boards.aspx");
        }
コード例 #6
0
        protected void CreatePostButton_Click(object sender, EventArgs e)
        {
            {
                SQLDatabase.DatabaseTable posts_table = new SQLDatabase.DatabaseTable("Posts");                                                                     // Need to load the table we're going to insert into.

                SQLDatabase.DatabaseRow new_row = posts_table.NewRow();                                                                                             // Create a new based on the format of the rows in this table.

                string new_id = posts_table.GetNextID().ToString();                                                                                                 // Use this to create a new ID number for this module. This new ID follows on from the last row's ID number.
                SQLDatabase.DatabaseTable loggedintable = new SQLDatabase.DatabaseTable("Users", "SELECT Username from Users WHERE ID = " + Session["LoggedinID"]); // get username from userdb using sessionid

                //get username from loggedintable where userid == LoggedinID
                string creatorname = loggedintable.GetRow(0)["Username"];
                string str         = "";
                if (Session["LoggedinID"] != null)
                {
                    str = Session["LoggedinID"].ToString();
                }
                int    creatorid    = Convert.ToInt32(str);
                string boardnum     = Session["Boards"].ToString();
                int    boardid      = int.Parse(boardnum);
                string creationdate = DateTime.Today.ToString("ddd dd MMM yyyy");
                string creationtime = DateTime.Now.ToString("HH:mm");

                new_row["ID"]          = new_id;                            // Add some data to the row (using the columns names in the table).
                new_row["Text"]        = CreatePostTextBox.Text.ToString(); // post contents.
                new_row["CreatorID"]   = creatorid.ToString();
                new_row["BoardID"]     = boardid.ToString();
                new_row["DateCreated"] = creationdate;
                new_row["TimeCreated"] = creationtime;

                posts_table.Insert(new_row);                           // Execute the insert - add this new row into the database.
            }
        }
コード例 #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SQLDatabase.DatabaseTable boards_table = new SQLDatabase.DatabaseTable("Boards");   // Need to load the table we're going to display...

            boards_table.Bind(DataList1);

            Label1.Text = Session["LoggedinID"].ToString();
        }
コード例 #8
0
        protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
        {
            if (e.CommandName == "deleteUser")     //functionality for deleting a user
            {
                SQLDatabase.DatabaseTable tUsers = new SQLDatabase.DatabaseTable("Users", "DELETE FROM Users WHERE ID = " + e.CommandArgument.ToString());

                Response.Redirect("AdminPage.aspx"); //refreshes page to show that the user has been deleted
            }
        }
コード例 #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["LoggedinID"] == null)
            {
                Response.Redirect("~/index.aspx");
            }
            SQLDatabase.DatabaseTable users_table = new SQLDatabase.DatabaseTable("Users");   // Need to load the table we're going to display...

            users_table.Bind(DataList3);
        }
コード例 #10
0
        protected void LoginButton_Click(object sender, EventArgs e)
        {
            SQLDatabase.DatabaseTable users_table = new SQLDatabase.DatabaseTable("Users");
            string UserText = UsernameTextbox.Text;
            string PassText = PasswordTextbox.Text;

            //initialise some empty strings
            string userIdHolder   = "";
            string UserNameHolder = "";
            string PasswordHolder = "";
            string UserTypeHolder = "";


            //iterate through the users database rows to find the user

            for (int i = 0; i < users_table.RowCount; i++)
            {
                userIdHolder   = users_table.GetRow(i)["ID"];
                UserNameHolder = users_table.GetRow(i)["Username"];
                PasswordHolder = users_table.GetRow(i)["Password"];
                UserTypeHolder = users_table.GetRow(i)["UserType"];

                if (UserNameHolder == UserText)
                //if usernames match
                {
                    if (PasswordHolder == PassText)
                    //if passwords also match
                    {  //Log them in
                       //store info in session variable to be accessed later
                        Session["LoggedinID"] = userIdHolder;
                        //Can call it later with
                        //string abc = Session["LoggedinID"].ToString();

                        //update last loggin in date??
                        DateTime thisDay = DateTime.Today;
                        Session["LastLoginTime"] = thisDay;

                        //go to boards page
                        Response.Redirect("~/board.aspx");
                    }
                    else
                    {
                        ErrorLabel.Text = "wrong password";
                    }
                }
                else
                {
                    ErrorLabel.Text = "No user by that name!";
                }
            }
        }
コード例 #11
0
        protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
        {
            if (e.CommandName == "openBoard")   //stores the boardID of the board that has been clicked into a session for later use
            {
                Session["BoardID"] = e.CommandArgument.ToString();
                SQLDatabase.DatabaseTable boardName = new SQLDatabase.DatabaseTable("Boards", "SELECT * FROM Boards");

                int i = Convert.ToInt32(e.CommandArgument.ToString());

                Session["BoardName"] = boardName.FindRow("ID", e.CommandArgument.ToString())["Name"];

                Response.Redirect("posts.aspx?id=" + Session["BoardID"]);
            }
        }
コード例 #12
0
        protected void CreateBoardButton_Click(object sender, EventArgs e)
        {
            SQLDatabase.DatabaseTable boards_table = new SQLDatabase.DatabaseTable("Boards"); // Need to load the table we're going to insert into.

            SQLDatabase.DatabaseRow new_row = boards_table.NewRow();                          // Create a new based on the format of the rows in this table.

            string new_id      = boards_table.GetNextID().ToString();                         // Use this to create a new ID number for this module. This new ID follows on from the last row's ID number.
            string creatorname = "1";
            int    creatorid   = int.Parse(creatorname);

            new_row["ID"]        = new_id;                             // Add some data to the row (using the columns names in the table).
            new_row["Name"]      = CreateBoardTextbox.Text.ToString(); // topic name.
            new_row["CreatorID"] = creatorid.ToString();

            boards_table.Insert(new_row);                           // Execute the insert - add this new row into the database.
        }
コード例 #13
0
        protected void DataList3_ItemCommand(object source, DataListCommandEventArgs e)
        {
            if (e.CommandName == "View")    // ViewButton clicked - but which one?
            {
                // Find the index of the button - which indicates which row...

                int index = int.Parse((string)e.CommandArgument);                               // The 'Command Argument' is a string, so turn it into an integer...

                SQLDatabase.DatabaseTable users_table = new SQLDatabase.DatabaseTable("Users"); // Need to load the table again, to extract the row in which the button was clicked.

                SQLDatabase.DatabaseRow row = users_table.GetRow(index);                        // Get the row from the table.

                Session["ID"] = row;                                                            // Store this on the Session, so we can access this module in the other page.

                Response.Redirect("#");                                                         // Now to go the other page to view the module information...
            }
        }
コード例 #14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["LoggedinID"] == null)
            {
                Response.Redirect("~/index.aspx");
            }
            SQLDatabase.DatabaseTable posts_table = new SQLDatabase.DatabaseTable("Posts");   // Need to load the table we're going to display...

            posts_table.Bind(DataList2);

            SQLDatabase.DatabaseTable loggedintable = new SQLDatabase.DatabaseTable("Users", "SELECT Username from Users WHERE ID = " + Session["LoggedinID"]);  // get username from userdb using sessionid

            //get username from loggedintable where userid == LoggedinID
            string Username = loggedintable.GetRow(0)["Username"];

            Label2.Text = Session["LastLoginDay"].ToString();
            Label1.Text = Username;
        }
コード例 #15
0
        protected void btnPass_Click(object sender, EventArgs e)
        {
            {
                string newPassword = txtNewPass.Text;

                if (txtNewPass.Text == String.Empty || txtOldPass.Text == String.Empty)  //validation for empty textboxes
                {
                    lblPassMessage.Text    = "You have not completed one or more required fields";
                    lblPassMessage.Visible = true;
                    return;
                }

                SQLDatabase.DatabaseTable usernames = new SQLDatabase.DatabaseTable("Users", "SELECT * FROM Users");


                for (int i = 0; i < usernames.RowCount; i++) // loops through the users table to find the row of the
                                                             // current user stored on the session
                {
                    if (usernames.GetRow(i)["ID"] == Session["UserID"].ToString())
                    {
                        if (txtOldPass.Text == usernames.GetRow(i)["Password"]) // validation that the old password was correct
                        {
                            usernames.GetRow(i)["Password"] = newPassword;      //changes password
                            usernames.Update(usernames.GetRow(i));
                            lblPassMessage.Text    = "Password Successfully Changed";
                            lblPassMessage.Visible = true;
                            txtNewPass.Text        = "";
                            txtOldPass.Text        = "";
                            break;
                        }
                        else
                        {
                            lblPassMessage.Text    = "Incorrect Password";
                            lblPassMessage.Visible = true;
                        }
                    }
                }
            }
        }
コード例 #16
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            SQLDatabase.DatabaseTable user_table = new SQLDatabase.DatabaseTable("Users");
            // Need to load the table we're going to insert into.

            SQLDatabase.DatabaseRow new_row = user_table.NewRow();
            // Create new row based on the format of the rows in this table.

            string new_id = user_table.GetNextID().ToString();

            // Use this to create a new ID number for this user. This new ID follows on from the last row's ID number.

            new_row["ID"] = new_id;
            // Add some data to the row (using the columns names in the table).
            new_row["Name"]     = TextBox3.Text.ToString();
            new_row["Username"] = TextBox1.Text.ToString();
            new_row["Password"] = TextBox2.Text.ToString();

            user_table.Insert(new_row);
            Label1.Text = "You have registered as: " + TextBox1.Text.ToString() + " password: "******", " + TextBox3.Text.ToString() + ".";
            // Execute the insert - add this new row into the database.
        }
コード例 #17
0
ファイル: board.aspx.cs プロジェクト: Alyzande/BulletinBoard
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session["LoggedinID"] == null)
                {
                    Response.Redirect("~/index.aspx");
                }

                SQLDatabase.DatabaseTable boards_table = new SQLDatabase.DatabaseTable("Boards");   // load boards db

                boards_table.Bind(DataList1);

                SQLDatabase.DatabaseTable loggedintable = new SQLDatabase.DatabaseTable("Users", "SELECT Username from Users WHERE ID = " + Session["LoggedinID"]);  // get username from userdb using sessionid

                //get username from loggedintable where userid == LoggedinID

                string Username = loggedintable.GetRow(0)["Username"];

                Label2.Text = Session["LastLoginDay"].ToString();
                Label1.Text = Username;
            }
        }
コード例 #18
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            string   email    = txtEmail.Text;
            string   password = txtPassword.Text;
            DateTime dt       = DateTime.Now; //gets current Date and Time from the system

            SQLDatabase.DatabaseTable usernames = new SQLDatabase.DatabaseTable("Users", "SELECT * FROM Users");

            for (int i = 0; i < usernames.RowCount; i++) //loops through the users table to validate if the username and password are linked to a user in the db
            {
                SQLDatabase.DatabaseRow row = usernames.GetRow(i);
                if (row["Username"] == email && row["Password"] == password)
                {
                    Session["TempLastLoginDate"] = row["LastLoginDate"];    //stores the last login date/time before they log in and it is updated.
                    Session["TempLastLoginTime"] = row["LastLoginTime"];    //this is to show them their last login date/time after they login


                    row.Add("LastLoginDate", dt.ToString("dddd, dd MMMM yyyy")); //updates their last login date/time to the current date/time
                    row.Add("LastLoginTime", dt.ToString("h: mm tt"));
                    usernames.Update(row);



                    Session["UserID"]        = row["ID"]; //stores all their info in sessions for easy access later.
                    Session["Name"]          = row["Name"];
                    Session["Username"]      = row["Username"];
                    Session["UserType"]      = row["UserType"];
                    Session["LastLoginDate"] = row["LastLoginDate"];
                    Session["LastLoginTime"] = row["LastLoginTime"];

                    Response.Redirect("Boards.aspx");
                }
            }

            lblLogMessage.Text    = "Username or Password not valid";
            lblLogMessage.Visible = true;
        }
コード例 #19
0
ファイル: board.aspx.cs プロジェクト: Alyzande/BulletinBoard
        protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                DataListItem            i = e.Item;
                System.Data.DataRowView r = ((System.Data.DataRowView)e.Item.DataItem); // 'r' represents the next row in the table that has been passed here via the 'bind' function.

                // Find the label controls that are associated with this data item.

                Label Topic_LBL   = (Label)e.Item.FindControl("Topic_Label");   // Find the Name Label.
                Label Creator_LBL = (Label)e.Item.FindControl("Creator_Label"); // Find the Staff ID Label.

                SQLDatabase.DatabaseTable users_table = new SQLDatabase.DatabaseTable("Users", "SELECT Username from Users WHERE ID = " + r["CreatorID"].ToString());
                string Username = users_table.GetRow(0)["Username"];


                Topic_LBL.Text   = r["Name"].ToString();         // Topic name.
                Creator_LBL.Text = Username;

                Button ViewButton = (Button)e.Item.FindControl("ViewButton"); // Find the button in this row.
                ViewButton.CommandArgument = i.ItemIndex.ToString();          // Allocate the row number to the 'command argument' property of the button, so we can identify which button was pressed later.
                ViewButton.CommandName     = "View";
            }
        }
コード例 #20
0
        protected void btnRegister_Click1(object sender, EventArgs e)
        {
            string id;
            string email       = txtEmail.Text;
            string password    = txtPassword.Text;
            string displayName = txtDisplayName.Text;
            string userType    = "User";
            bool   emailFound  = false;
            bool   nameFound   = false;


            if (txtDisplayName.Text == String.Empty || txtEmail.Text == String.Empty || txtPassword.Text == String.Empty) //validation for empty textboxes
            {
                lblRegMessage.Text    = "You have not completed one or more required fields";
                lblRegMessage.Visible = true;
                return;
            }

            SQLDatabase.DatabaseTable tUsers = new SQLDatabase.DatabaseTable("Users");

            SQLDatabase.DatabaseRow row = tUsers.NewRow();

            row.Add("ID", tUsers.GetNextID().ToString()); // adds all required details to create a user
            row.Add("Name", displayName);
            row.Add("Username", email);
            row.Add("Password", password);
            row.Add("UserType", userType);

            SQLDatabase.DatabaseTable usernames = new SQLDatabase.DatabaseTable("Users", "SELECT * FROM Users");

            for (int i = 0; i < usernames.RowCount; i++) //loops through the user table to check if the inputted email is already taken by another user
            {
                if (usernames.GetRow(i)["Username"] == email)
                {
                    emailFound = true;
                    break;
                }
            }

            for (int n = 0; n < usernames.RowCount; n++) //loops through the user table to check if the inputted email is already taken by another user
            {
                if (usernames.GetRow(n)["Name"] == displayName)
                {
                    nameFound = true;
                    break;
                }
            }

            if (!emailFound && !nameFound) // if neither are duplicates then add the user
            {
                tUsers.Insert(row);
            }
            else
            {
                if (emailFound && !nameFound) //if email is taken but display name not, tell the user
                {
                    lblRegMessage.Text = "That Email Address is already taken, please enter a different one.";
                }
                if (nameFound && !emailFound) //if display name is taken but email not, tell the user
                {
                    lblRegMessage.Text = "That Display Name is already taken, please enter a different one.";
                }
                if (nameFound && emailFound) //if display name  and email are taken, tell the user
                {
                    lblRegMessage.Text = "That Display Name and Email Address is already taken, please enter a different one.";
                }

                lblRegMessage.Visible = true;
                return;
            }

            SQLDatabase.User u = tUsers.GetUser(0); // stores the users into a class incase they are needed in the future

            id          = u.ID;
            displayName = u.displayName;
            email       = u.email;
            password    = u.password;
            u.userType  = userType;

            Response.Redirect("Default.aspx");
        }
コード例 #21
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SQLDatabase.DatabaseTable posts_table = new SQLDatabase.DatabaseTable("Posts");   // Need to load the table we're going to display...

            posts_table.Bind(DataList2);
        }
コード例 #22
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SQLDatabase.DatabaseTable users_table = new SQLDatabase.DatabaseTable("Users");   // Need to load the table we're going to display...

            //  users_table.Bind(DataList4);
        }
コード例 #23
0
ファイル: index.aspx.cs プロジェクト: Alyzande/BulletinBoard
        protected void LoginButton_Click(object sender, EventArgs e)
        {
            SQLDatabase.DatabaseTable users_table = new SQLDatabase.DatabaseTable("Users");
            string UserText = UsernameTextbox.Text;
            string PassText = PasswordTextbox.Text;

            //initialise some empty strings
            string userIdHolder   = "";
            string UserNameHolder = "";
            string PasswordHolder = "";
            string UserTypeHolder = "";


            //iterate through the users database rows to find the user

            for (int i = 0; i < users_table.RowCount; i++)
            {
                userIdHolder   = users_table.GetRow(i)["ID"];
                UserNameHolder = users_table.GetRow(i)["Username"];
                PasswordHolder = users_table.GetRow(i)["Password"];
                UserTypeHolder = users_table.GetRow(i)["UserType"];

                if (UserNameHolder == UserText)
                //if usernames match
                {
                    if (PasswordHolder == PassText)
                    //if passwords also match
                    {  //Log them in
                       //store info in session variable to be accessed later
                        Session["LoggedinID"] = userIdHolder;
                        //Can call it later with
                        //string abc = Session["LoggedinID"].ToString();

                        //update last loggin in date

                        Session["LastLoginDay"]  = DateTime.Today.ToString("ddd dd MMM yyyy");
                        Session["LastLoginTime"] = DateTime.Now.ToString("HH:mm");
                        //ErrorLabel.Text = "Logging in as " + Session["LoggedinID"].ToString() + "...";

                        //update the database with the logging in date and logging in time


                        for (int n = 0; n < users_table.RowCount; ++n)
                        {
                            SQLDatabase.DatabaseRow row = users_table.GetRow(n); //get current ID.
                            if (userIdHolder == users_table.GetRow(n)["ID"])     //if userID is the same as it's in the row
                            {
                                row["LastLoginDate"] = Session["LastLoginDay"].ToString();
                                row["LastLoginTime"] = Session["LastLoginTime"].ToString();
                                users_table.Update(row);
                            }
                        }

                        //go to boards page
                        Response.Redirect("~/board.aspx");
                    }
                    else
                    {
                        ErrorLabel.Text = "wrong password";
                    }
                }
                else
                {
                    ErrorLabel.Text = "No user by that name!";
                }
            }
        }