𝔳𝔞𝔪𝔭𝔲𝔯𝔯
𝔳𝔞𝔪𝔭𝔲𝔯𝔯
CC#
Created by 𝔳𝔞𝔪𝔭𝔲𝔯𝔯 on 7/28/2023 in #help
❔ Error on my try and catch
It says that the variable 'ex' is declared but never used and how do i make the username and password more secure?
[HttpPost]
public IActionResult AppUserLogin(AppUser user)
{
string connectionString = "server=db4free.net;database=rpxxxxx;uid=rpxxxx;pwd=rpxxxxx;";
MySqlConnection connection = new MySqlConnection(connectionString);
try
{
connection.Open();
string sql = "SELECT Email,Password FROM AppUser WHERE Email= '" + user.Email + "' AND password = '" + user.Password + "'";
MySqlCommand command = new MySqlCommand(sql, connection);
command.ExecuteNonQuery();
TempData["Msg"] = "Successfully login!";
connection.Close();
}
catch (Exception ex)
{
TempData["Msg"] = "Incorrect email or password";
}


return RedirectToAction("Main");

}
[HttpPost]
public IActionResult AppUserLogin(AppUser user)
{
string connectionString = "server=db4free.net;database=rpxxxxx;uid=rpxxxx;pwd=rpxxxxx;";
MySqlConnection connection = new MySqlConnection(connectionString);
try
{
connection.Open();
string sql = "SELECT Email,Password FROM AppUser WHERE Email= '" + user.Email + "' AND password = '" + user.Password + "'";
MySqlCommand command = new MySqlCommand(sql, connection);
command.ExecuteNonQuery();
TempData["Msg"] = "Successfully login!";
connection.Close();
}
catch (Exception ex)
{
TempData["Msg"] = "Incorrect email or password";
}


return RedirectToAction("Main");

}
33 replies
CC#
Created by 𝔳𝔞𝔪𝔭𝔲𝔯𝔯 on 7/12/2023 in #help
❔ phpmyadmini database to vs
6 replies