i am new on asp.net.
i want to know how to check my username and password by using MYSQL...
i use the following code behing my .cs file
MySqlConnection conn = new MySqlConnection("Server=localhost;Database=dbabc;Uid=root;Pwd=;");
protected void Page_Load(object sender, EventArgs e)
{
try
{
conn.Open();
Response.Write("MySQL conenct successfully");
}
catch (MySqlException error)
{
Response.Write("MySQL could not be connect to the server try agian!");
}
}
protected void signin_btn_Click(object sender, EventArgs e)
{
int i=0;
string sql = "SELECT username, password from login where username='" + username_tb + "' and password = '" + password_tb + "'" ;
MySqlCommand cmd = new MySqlCommand(sql, conn);
MySqlDataReader rdr = cmd.ExecuteReader();
if (rdr.Read())
{
result.InnerText = rdr[0].ToString();
}
else
{
result.InnerText = "Sorry record Not found!";
}
conn.Close();
}
and these are the following code in index.aspx
Username : <input type="text" id="username_tb" name="username_tb" style="weight:250px; height: 25px;" runat="server"></input><br />
Password : <input type="password" id="password_tb" name="password_tb" style="weight:250px; height:25px;" runat="server"></input><br />
<input type="submit" name="submit" value="Signin" style="weight:30px; height:25px; margin-top: 3px;" runat="server" onserverclick="signin_btn_Click"></input><br />
</div>
<label id="result" runat="server"></label>
so finally i need to say that i want a result which says username and password are correct in case of sucess and username and password was not correct in case of failure