Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Data.SqlClient;
- using System.Data;
- using System;
- using System.Configuration;
- using System.Text;
- using System.Collections.Generic;
- using System.Linq;
- using System.Xml.Linq;
- public partial class Index : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- }
- protected void BtnLogin_Click(object sender, EventArgs e)
- {
- SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["Data Source=Server;Initial Catalog=DB;Integrated Security=True"].ConnectionString);
- conn.Open();
- string checkuser = "SELECT Username FROM USER WHERE Username='" + TextBoxUser.Text + "'";
- SqlCommand com = new SqlCommand(checkuser, conn);
- int temp = Convert.ToInt32(com.ExecuteScalar().ToString());
- conn.Close();
- if (temp == 1)
- {
- conn.Open();
- string checkPasswordQuery = "SELECT Password FROM USER WHERE Password= '" + TextBoxPassword.Text + "'";
- SqlCommand passCom = new SqlCommand(checkPasswordQuery, conn);
- string password = passCom.ExecuteScalar().ToString().Replace(" ", "");
- if (password == TextBoxPassword.Text)
- {
- Session["New"] = TextBoxUser.Text;
- Response.Redirect("~/main.aspx");
- }
- else
- {
- Response.Redirect("~/password_in.aspx");
- }
- }
- else
- {
- Response.Redirect("~/password_in.aspx");
- }
- }
- public class TextBoxUser
- {
- internal static string Text;
- }
- public class TextBoxPassword
- {
- internal static string Text;
- }
- }
Add Comment
Please, Sign In to add comment