Login e senha
Boa tarde a todos!!!
Eu tenho uma pagina chamada acesso_restrito.php e nela tem os campos LOGIN E SENHA, para se logar ele envia os dados via POST para outra pagina, ela faz a verificação e redireciona passando algumas informações para a sessão!!!
Eu gostaria de fazer assim, digita login e senha, envia para a mesma pagina os dados, e la ele verifica e se existir o usuario ele redireciona, caso não, ele da uma msg de DADOS INCORRETOS....
Segue abaixo o codigo que estou tentando desenvolver para isso.!!!
PS: Peguei em andamento e estou tentando melhorar.
<?php
if ($_POST["acao"] = "exe") {
session_start(); // Inicia a session
include ("consulta/config.php");
$usuario = $_POST['usuario'];
$senha = $_POST['senha'];
if((!$usuario) || (!$senha)){
//REDIRECIONAMOS PARA A PÁGINA QUE VAI EXIBIR OS DADOS
$msg = "Dados Incorretos";
}else{
$senha = md5($senha);
$sql = mysql_query("SELECT * FROM usuarios WHERE usuario='{$usuario}' AND senha='{$senha}' AND ativado='1'");
$login_check = mysql_num_rows($sql);
if($login_check > 0){
while($row = mysql_fetch_array($sql)){
foreach( $row AS $key => $val ){
$$key = stripslashes( $val );
}
$no_acesso = $row["no_acesso"];
$soma = $no_acesso + 1;
$resultado = $soma;
//PEGA OS DADOS DO MYSQL E ATRIBUIMOS O VALOR A VARIAVEL
$nivel = mysql_result($sql, 0, "nivel");
$_SESSION['usuario_id'] = $usuario_id;
$_SESSION['cod_cli'] = $cod_cli;
$_SESSION['usuario'] = $usuario;
$_SESSION['nome'] = $nome;
$_SESSION['sobrenome'] = $sobrenome;
$_SESSION['email'] = $email;
$_SESSION['nivel_usuario'] = $nivel_usuario;
$_SESSION['nm_empresa'] = $nm_empresa;
$_SESSION['nivel'] = $nivel;
$_SESSION['telcom'] = $telcom;
mysql_query("UPDATE usuarios SET no_acesso='$resultado', data_ultimo_login = now() WHERE usuario_id ='{$usuario_id}'");
Header("Location: [url="[http://seccon.no-ip.info:81/consulta/consulta.php?usuario_logado");"]http://seccon.no-ip.info:81/consulta/consu..._logado");[/url]](http://seccon.no-ip.info:81/consulta/consulta.php?usuario_logado)
//header ("<script>window.close();<script>");
exit;
}
}
Header("Location: [url="[http://www.seccon.com.br/acesso_restrito.php?usuario_errado");"]http://www.seccon.com.br/acesso_restrito.p..._errado");[/url]](http://www.seccon.com.br/acesso_restrito.php?usuario_errado)
}
}
?>
<? include ("topo.php"); ?>
<style type="text/css"><!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}-->
</style>
<link href="consulta/styles/styles.css" rel="stylesheet" type="text/css">
<form action="[http://www.seccon.com.br/acesso_restrito.php"](http://www.seccon.com.br/acesso_restrito.php) method="post" name="form" id="form">
<table width="450" height="232" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="1" height="0" bgcolor="#CCCCCC"></td>
<td width="398" bgcolor="#FDFDFD">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="398"><table width="450" height="232" border="0" cellpadding="5" cellspacing="0" background="arquivos/imagem_padrao/area_restrita.gif">
<tr>
<td><br><br><br><br>
<table width="308" border="0" align="center" cellpadding="3" cellspacing="0">
<tr>
<td width="92" height="0"><div align="right" class="verdana10BLACKBold"></div></td>
<td height="0" colspan="2"></td>
</tr>
<tr>
<td width="92" height="0"><div align="right" class="verdana10BLACKBold">Login:</div></td>
<td height="0" colspan="2"><input style="border:1px solid #6E7C81; FONT-SIZE: 8pt; FONT-FAMILY: Verdana; padding-left:4; padding-right:4; padding-top:1; padding-bottom:1" name="usuario" type="text" id="usuario" size="15"></td>
</tr>
<tr>
<td width="92" height="0"><div align="right" class="verdana10BLACKBold">Senha:</div></td>
<td width="75" height="0"><input style="border:1px solid #6E7C81; FONT-SIZE: 8pt; FONT-FAMILY: Verdana; padding-left:4; padding-right:4; padding-top:1; padding-bottom:1" name="senha" type="password" id="senha" size="15"></td>
<td width="123" height="0"><input name="Submit" type="submit" value="Entrar" class="verdana9BOLD")>
<input name="acao" type="hidden" id="acao" value="exe">
</td>
<tr>
<td width="92" height="0"></td>
<td width="75" height="0"></td>
<td width="123" height="0"><INPUT type=button value="Recuperar Senha" class="verdana9BOLD" onClick="window.open('http://www.seccon.com.br/consulta/gerar_nova_senha.php','janela_1','menubar=disable,resizable=disable,width=250,height=150');">
</td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table></td>
<td width="1" height="0" bgcolor="#CCCCCC"></td>
</tr>
</table></form>
<? include ("base.php");?>Discussão (5)
Carregando comentários...