Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Data.SqlClient;
- using System.Configuration;
- public partial class Login : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["PagConnectionString"].ConnectionString);
- con.Open();
- string cmdStr = "Select count(*) from Registration where Username=";
- cmdStr = cmdStr + "";
- cmdStr = cmdStr + TextBoxUN.Text;
- cmdStr = cmdStr + "";
- SqlCommand CheckUser = new SqlCommand(cmdStr, con);
- int temp = Convert.ToInt32(CheckUser.ExecuteScalar().ToString());
- if ( temp== 1)
- {
- string cmdStr2 = "Select Password from Registration where Username=" + TextBox2.Text + "";
- SqlCommand pass = new SqlCommand(cmdStr2, con);
- string password = pass.ExecuteScalar().ToString();
- con.Close();
- if (password == TextBox2.Text)
- {
- Session["New"] = TextBoxUN.Text;
- Response.Redirect("Secure.aspx");
- }
- else
- {
- Label1.Visible = true;
- Label1.Text = "Invalid Password";
- }
- }
- else
- {
- Label1.Visible = true;
- Label1.Text = "Invalid Username";
- }
- }
- }
Add Comment
Please, Sign In to add comment