I have a website ready, but I want my program to check the user login on the site. Basically it can register in both and access both with the same user (The site and the system uses the same database). But I'm not able to do this check by the system.
<?php include "./config/global.php";
error_reporting(E_ALL);
if(isset($_SESSION['login23'])){
echo '<script>location.href="principal.php";</script>';
}
?>
<?php include "php/head.php";?>
<title>Entrar - <?php echo $titulocf;?></title>
<style type="css">
.text-transform: lowercase;
</style>
<audio src="" autoplay></audio>
</head>
<body>
<form action="" id="validate" class="form-horizontal" method="POST" role="form">
<?php
if(isset($_POST['enviar_cadastro']) && $_POST['enviar_cadastro'] == 'envia'){
?>
<div style="display:none;">
</div>
<?php
$login = $_POST['login'];
$login = antiSQL($login);
$senha = $_POST['senha'];
$senha = antiSQL($senha);
$query1 = "SELECT * FROM clientes WHERE login='$login' AND senha='$senha' AND suspenso='nao'";
$query1 = mysql_query($query1);
$total1 = mysql_num_rows($query1);
$select = "SELECT * FROM clientes WHERE login='$login'";
$result = mysql_query($select);
while($l = mysql_fetch_array($result)){
$suspenso = $l['suspenso'];
}
if($total1 == "1"){
$_SESSION['login23'] = $login;
$login23 = $_SESSION['login23'];
$log = "Usuario entrou no Painel de Controle !";
$ip = $_SERVER['REMOTE_ADDR'];
$hora = date("h:i:s");
$data = date("d/m/Y");
$genero = "entrou";
$registro = "$data ás $hora";
$insert = "INSERT INTO log (log, ip, data, autor, genero) VALUES ('$log', '$ip', '$registro', '$login', '$genero')";
$resultado = mysql_query($insert) or die ("");
echo '<script language= "JavaScript">location.href="principal.php"</script>';
}if($total1 == "0"){
$login_error="<b>Login</b>, ou <b>Senha</b> incorretos !";
}
}?>
<div class="login-container animated fadeInDown">
<div class="loginbox bg-white">
<div class="loginbox-title"><span class="text-info">MM</span><span>onitor</span>
</div>
<div class="loginbox-social">
<div class="social-title ">Entre na sua conta</div>
</div>
<div class="loginbox-or">
<div class="or-line"></div>
</div>
<?php if(isset($login_error)){
if ($suspenso == "sim") {
echo '<div class="alert alert-danger fade in radius-bordered alert-shadowed">
<button class="close" data-dismiss="alert">
×
</button>
<i class="fa-fw fa fa-times"></i>
<strong>Erro</strong> Hotel suspenso.
</div>';
}
elseif (empty($login)) {
echo '<div class="alert alert-danger fade in radius-bordered alert-shadowed">
<button class="close" data-dismiss="alert">
×
</button>
<i class="fa-fw fa fa-times"></i>
<strong>Erro</strong> Informe um usuário e senha.
</div>';
}else{
echo '<div class="alert alert-danger fade in radius-bordered alert-shadowed">
<button class="close" data-dismiss="alert">
×
</button>
<i class="fa-fw fa fa-times"></i>
<strong>Erro</strong> Usuário ou senha incorretos.
</div>';
}
} ?>
<div class="loginbox-textbox">
<input type="text" name="login" autocomplete="off" class="form-control" placeholder="Usuário" />
</div>
<div class="loginbox-textbox">
<input type="password" name="senha" class="form-control" placeholder="Senha" />
</div>
<div class="loginbox-forgot">
<a href="senha.php">Esqueçeu sua senha?</a>
</div>
<div class="loginbox-submit">
<input type="hidden" name="enviar_cadastro" value="envia" /> <input type="submit" class="btn btn-primary btn-block" value="Entrar">
</div>
</div>
</form>
<div class="logobox">
</div>
</div>
</body>
</html>
string usuario = "admin";
string senha = "admin";
ASCIIEncoding encoding = new ASCIIEncoding();
string postData = "login=" + usuario;
postData += ("senha=" + senha);
byte[] data = encoding.GetBytes(postData);
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create("http://localhost/");
myRequest.Method = "POST";
myRequest.ContentType = "application/x-www-form-urlencoded";
myRequest.ContentLength = data.Length;
Stream newStream = myRequest.GetRequestStream();
// Send the data.
newStream.Write(data, 0, data.Length);
StreamReader reader = new StreamReader(newStream);
newStream.Close();
MessageBox.Show(reader.ToString());