|
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.Data;
namespace SampleHacking
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Session["user"]=txt1.Text;
}
protected void Login_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|UserDetails.mdf;Integrated Security=True;User Instance=True");
conn.Open();
//SqlDataAdapter da = new SqlDataAdapter("Select Username from Authentication",conn);
//DataTable dtCheckUsername = new DataTable();
//da.Fill(dtCheckUsername);
//dtCheckUsername.DefaultView.Sort = "Username";
//int usernameRowIndex = dtCheckUsername.DefaultView.Find(txt1.Text);
//SqlDataAdapter da1 = new SqlDataAdapter("Select Password from Authentication", conn);
//DataTable dtCheckPassword = new DataTable();
//da1.Fill(dtCheckPassword);
//dtCheckPassword.DefaultView.Sort = "Password";
//int passwordRowIndex=dtCheckPassword.DefaultView.Find(txt2.Text);
//if (usernameRowIndex != -1 && passwordRowIndex != -1)
//{
SqlDataAdapter sda = new SqlDataAdapter("SELECT * FROM Authentication where Username='" + txt1.Text + "'and password='" + txt2.Text + "'", conn);
DataTable dt = new DataTable();
sda.Fill(dt);
conn.Close();
if (dt.Rows.Count != 0)
{
Response.Redirect("Redirected.aspx");
}
else
{
errorlbl.Text = "Incorrect username and password";
}
//}
//else
//{
// errorlbl.Style.Add("Color", "red");
// errorlbl.Style.Add("font-weight", "bold");
// errorlbl.Text = "You are not an Authorised User to enter this site!!";
//}
}
protected void SignUp_Click(object sender, EventArgs e)
{
Response.Redirect("SignUp.aspx");
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.