C#
Код: Выделить всё
private void LoginBT_Click(object sender, EventArgs e)
{
/* LoginBT - кнопка
loTXT - лабел логина
psTXT - лабел пароля
AutPanel - панель на которой находяться лабелы и нужные кнопки
*/
const String CorrectAuthText = "Авторизация прошла успешно";
var request = (HttpWebRequest)WebRequest.Create("http://yoursite.ru/launcher-aut.php");
var postData = "LoginBT = True";
postData += "&login =" + loTXT.Text;
postData += "&password =" + psTXT.Text;
var data = Encoding.ASCII.GetBytes(postData);
request.Method = "POST";
request.ContentType = "application / x - www - form - urlencoded";
request.ContentLength = data.Length;
using (var stream = request.GetRequestStream())
{ stream.Write(data, 0, data.Length); }
var response = (HttpWebResponse)request.GetResponse();
var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
if (responseString.Contains(CorrectAuthText))
{
AutPanel.Visible = false;
MessageBox.Show("Авторизованы!");
}
else
{
MessageBox.Show("Не удалось авторизоваться!");
}
Код: Выделить всё
<?php
$mylogin = ‘admin’;
$mypass = ‘root’;
if(isset($_POST[‘LoginBT’]))
{
if (($_POST[‘login’] == $mylogin) && ($_POST[‘password’] == $mypass))
{
echo ’Авторизация прошла успешно’;
}
else
{
echo ’ Неверные данные’;
}
}
else
{
echo(‘
<form method=»post»>
Логин: <input type=»text» name=»login» />
Пароль: <input type=»password» name=»password» />
<input type=»submit» value=»Войти» name=»btn_auth» />
</form>
‘);
?>
Заранее благодарю.