Problema de Undefined index
Bom dia , sou iniciante no PHP e estou com um probleminha de não reconhecer a variável , utilizo uma pagina de login e uma config
utilizando o Include na pagina de login
não chega nem a digitar o login ja aparece a mensagem de Undefined Index ;
Quando utilizo autenticação simples funciona
quando insiro a tabela para ler usuário e senha não reconhece as variáveis login e senha.
segue o codigo
loginc.php
<?php
session_start();
set_time_limit(0);
$pagina_login = 1;
include 'configc.php';
include 'functionsc.php';
if (isset($_GET['sair'])) {
$_SESSION['logado'] = "";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "url=[http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/url]
<html xmlns="[url=[http://www.w3.org/1999/xhtml](http://www.w3.org/1999/xhtml)][http://www.w3.org/1999/xhtml](http://www.w3.org/1999/xhtml)">[/url]
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="sortcut icon" href="images/logo_px.ico" type="image/x-icon" />
<title id='titulo'>Livro caixa <?php echo $lc_titulo ?></title>
<meta name="LANGUAGE" content="Portuguese" />
<meta name="AUDIENCE" content="all" />
<meta name="RATING" content="GENERAL" />
<link href="stylesc.css" rel="stylesheet" type="text/css" />
<script language="javascript" src="scriptsc.js"></script>
<center>
<iframe width='1010' height='175' frameborder='0' src='frame.php'></iframe>
</center>
<br />
</head>
<body style="padding:10px">
<table width="1009" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="5" align="center">
<?php
include("menu.html");
?>
</td>
</tr>
</table>
<br>
<table cellpadding="1" cellspacing="3" width="900" align="center" style="background-color:#033">
<tr>
<td colspan="11" style="background-color:#00F;">
<h2 style="color:#FFF; margin:5px">Livro Caixa - <?php echo $lc_titulo ?></h2>
</td>
<td colspan="2" align="right" style="background-color:#00F;">
<a style="color:#FFF" href="?mes=<?php echo date('m') ?>&ano=<?php echo date('Y') ?>">Hoje:<strong> <?php echo date('d') ?> de <?php echo mostraMes(date('m')) ?> de <?php echo date('Y') ?></strong></a>
</td>
</tr>
</table>
<br />
<table cellpadding="1" cellspacing="10" width="900" align="center" >
<tr>
<td colspan="11" align="center" >
Faca Login para entrar no sistema:
<br><br>
<form action="" method="post">
<?php echo $login = $_COOKIE['login']; ?>
Login: <input type='text' name='login' value="<?= $login; ?>" ><br>
Senha: <input type='password' name='senha' "><br>
<br>
<input type='submit' name='OK' value='Entrar'>
</form>
<br>
</td>
</tr>
</table>
<table cellpadding="5" cellspacing="0" width="900" align="center">
<tr>
<td align="right">
<hr size="1" />
<em>Livro Caixa - <strong><?php echo $lc_titulo ?></strong> - </em>
</td>
</tr>
</table>
</body>
</html>
configc.php
<?php
//Configuração do Banco de dados
$host = "localhost";
$user = "rsloc905_rslocar";
$pass = "88785335";
$d_b = "rsloc905_rslocar";
//Título do seu livro Caixa, geralmente seu nome
$lc_titulo="Voce Nao esta Logado";
//Autenticação simples
/*$usuario = $_GET['login'];
$senha = $_GET['senha'];*/
if (!isset($_COOKIE['login'])) {
echo "erro" .' - '. "login" .' - '. "variavel nao carregada";
exit();
}
else { $usuario = $_REQUEST['login'];
$senha = md5($_REQUEST['senha']); }
//////////////////////////////////////
//Não altere a partir daqui!
//////////////////////////////////////
$conn = mysql_connect($host, $user, $pass) or die("Erro na conexao com a base de dados");
$db = mysql_select_db($d_b, $conn) or die("Erro na selecao da base de dados");
$verifica = mysql_query("SELECT * FROM usuarios WHERE '$usuario' = login AND '$senha' = senha ") or die("erro ao selecionar");
if (mysql_num_rows($verifica)<=0){
echo"<script language='javascript' type='text/javascript'>alert('Login e/ou senha incorretos');window.location.href='index2.php';</script>";
die();
} else {
while ($row = mysql_fetch_array($verifica) )
{
$nivel = $row['nivel'];
}
}
/*if ($nivel == 'A') { $lc_titulo = #lc_titulo .'-'. $usuario;
header("Location: caixa.php");
exit();}
else { header("Location: index2.php");
exit(); } */
if ($nivel == 'A'){
if (isset($_SESSION['logado']))
$logado = $_SESSION['logado'];
else
$logado = "";
$senha_ = md5($senha);
if (isset($_POST['flogin']) && $_POST['flogin'] != '') {
if ($_POST['flogin'] == $usuario && $_POST['fsenha'] == $senha) {
$logado = $_SESSION['logado'] = md5($_POST['fsenha']);
header("Location: caixa.php");
exit();
}
}
echo $senha .' - ' .$logado;
if ($logado != $senha_ && !isset($pagina_login)) {
header("Location: index2.php");
exit();
echo md5($senha) .' - ' .$logado;
}
}
?>Discussão (1)
Carregando comentários...