Guest User

Untitled

a guest
Jan 24th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.58 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using System.Data.SqlClient;
  8. using System.Configuration;
  9.  
  10. public partial class Login : System.Web.UI.Page
  11. {
  12.     protected void Page_Load(object sender, EventArgs e)
  13.     {
  14.        
  15.     }
  16.     protected void btnLogin_Click(object sender, EventArgs e)
  17.     {
  18.         SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["KwSConnectionString"].ConnectionString);
  19.         con.Open();
  20.         string cmdStr= "Select count (*) from tblRegistration where username '" + txtPlayertag + '"';
  21.         SqlCommand checkUser = new SqlCommand(cmdStr, con);
  22.         int temp = Convert.ToInt32(checkUser.ExecuteScalar().ToString());
  23.        
  24.         if (temp == 1)
  25.         {
  26.             string cmdStr2 = "Select Password from tblRegistration where playertag '" + txtPlayertag + '"';
  27.             SqlCommand pass = new SqlCommand(cmdStr2, con);
  28.             string password = pass.ExecuteScalar().ToString();
  29.  
  30.             if (password == txtPassword.Text)
  31.             {
  32.                 Session["New"] = btnLogin;
  33.                 Response.Redirect("Secure.aspx");
  34.             }
  35.             else
  36.             {
  37.                 Label1.Visible = true;
  38.                 Label1.Text = "Invalid Password!";
  39.             }
  40.         }
  41.             else
  42.             {
  43.                 Label1.Visible = true;
  44.                 Label1.Text = "Invalid Playertag!";
  45.                
  46.            
  47.             }
  48.         con.Close();
  49.         }
  50.     }
Add Comment
Please, Sign In to add comment