Hi, Im trying you send different users to different pages when they login. Im using asp.net c# and a mysql database. The current problem id that when a run it and hit enter after entering the email and password nothing happens. They are set a role in the database when they register. Any help would be much appreciated. Thanks below is my code.
protected void Page_Load(object sender, EventArgs e)
{
this.UnobtrusiveValidationMode = System.Web.UI.UnobtrusiveValidationMode.None;
}
MySqlConnection con = new MySqlConnection("server=127.0.0.1;user id=root;persistsecurityinfo=True;database=fypdb;password=fypuser");
// enables the built-in validator controls to use unobtrusive JavaScript for client-side validation logic
protected void Button1_Click(object sender, EventArgs e)
{
con.Open();
MySqlCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "select * from login where EmailId='" + TxtEmailId.Text + "' and Password='" + TxtPassword.Text + "'";
cmd.ExecuteNonQuery();
MySqlDataAdapter sda = new MySqlDataAdapter(cmd);
DataTable dt = new DataTable();
sda.Fill(dt);
if (dt.Rows.Count != 0)
{
string Role;
Role = dt.Rows[0][7].ToString().Trim();
if (Role == "Student")
{
Session["Student"] = TxtEmailId.Text;
Response.Redirect("Homepage.aspx");
}
if (Role == "Landlord")
{
Session["Landlord"] = TxtEmailId.Text;
Response.Redirect("HouseReg.aspx");
}
}
else
{
lblError.Text = "Invalid Email or Password!";
}
}
}
}