Click here to Skip to main content
15,887,272 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
hi i need help to resolve my problem on getting 3 attempt security Log in and how to return to page after printing a document

What I have tried:

for my code in 3 attempt code

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Configuration;
using System.Data.SqlClient;
using MySql.Data.MySqlClient;
using MySql.Web;

namespace SchoolPortal
{
    public partial class registration : System.Web.UI.Page
    {
        static int attempts = 3;

        MySqlConnection conn = new MySqlConnection(@"Data Source =localhost;Uid=root;Pwd=secret;Database=payroll_system;");

        protected void Page_Load(object sender, EventArgs e)
        {

            if (Session["e"] != null && Session["password"] != null)
            {


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



        protected void btnLog_Click1(object sender, EventArgs e)

        {

            string value;
            int j = 0;
            DataSet ds = new DataSet();
            DataSet ds1 = new DataSet();
            using (MySqlConnection conn = new MySqlConnection(@"Data Source =localhost;Uid=root;Pwd=secret;Database=payroll_system;"))
            {
                conn.Open();
                MySqlCommand cmd = conn.CreateCommand();
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = "SELECT * from employee_info where password ='" + txtPass.Text + "' and employee_ID='" + txte.Text + "'";
                cmd.ExecuteNonQuery();
                DataTable dt = new DataTable();
                MySqlDataAdapter da = new MySqlDataAdapter(cmd);
                da.Fill(dt);

                foreach (DataRow dr in dt.Rows)
                {
                    Session["e"] = txte.Text;
                    Session["password"] = txtPass.Text;
                    Response.Redirect("employeelist.aspx");

                }
                conn.Close();
                attempts = 0;
                if (txte.Text != Session["e"] && txtPass.Text != Session["password"])
                {    
                    if((attempts < 3 ))
                    for (int i = 0; i <= j; i++) ;
                   
                    j = dt.Rows.Count + 1;
                   
                
                }
                   
                else
                {
                   


                    Label1.Text = (" Check your Email or Password as well as your Employee Identification if Correct then TRY AGAIN You have '" + j + "' tries left.") + 1;

                }


                 if (txte.Text == "" && txtPass.Text == "")
                {
                    Label1.Text = " Fill the need information";
                    txte.Focus();
                    return;
                }
                    
                    
            }
    }


and my code for print document using javascript

<td align="left">

              <button onclick="myFunction()">PRINT</button>
               <script>
                   function myFunction() {
                       window.print();
                       return;
                   }
               </script>

                 </td>
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900