Skip to content

Commit

Permalink
§
Browse files Browse the repository at this point in the history
  • Loading branch information
ThiagoSousa81 authored Jan 3, 2025
1 parent 7a7a222 commit 41da794
Showing 1 changed file with 45 additions and 1 deletion.
46 changes: 45 additions & 1 deletion EBS-LAB/frmLogin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private void btnSingUp_Click(object sender, EventArgs e)
Process.Start(new ProcessStartInfo(@"https://web.ebs-systems.epizy.com/singup") { UseShellExecute = true });
}

private async void btnLogin_Click(object sender, EventArgs e)
/* private async void btnLogin_Click(object sender, EventArgs e)
{
string user = txtUser.Text;
string pass = txtPassword.Text;
Expand Down Expand Up @@ -98,7 +98,51 @@ private async void btnLogin_Click(object sender, EventArgs e)
MessageBox.Show("Erro: " + ex.Message);
}
}
}*/

private async void btnLogin_Click(object sender, EventArgs e)
{
string user = txtUser.Text;
string pass = txtPassword.Text;

// URL do PHP com parâmetros GET
string url = $"https://ebs-web-auth.vercel.app/login?user={Uri.EscapeDataString(user)}&pwd={Uri.EscapeDataString(pass)}";

using (HttpClient client = new HttpClient())
{
try
{
// Envia a requisição GET para o PHP
HttpResponseMessage response = await client.GetAsync(url);

// Lê a resposta da API
string responseContent = await response.Content.ReadAsStringAsync();

// Se a resposta for de sucesso
if (response.IsSuccessStatusCode)
{
// Verifica se a resposta contém "success"
if (responseContent.Contains("success"))
{
MessageBox.Show("Login bem-sucedido!");
}
else
{
MessageBox.Show("Erro: " + responseContent);
}
}
else
{
MessageBox.Show("Erro ao conectar com a API");
}
}
catch (Exception ex)
{
MessageBox.Show("Erro: " + ex.Message);
}
}
}


}
}

0 comments on commit 41da794

Please sign in to comment.