Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Bom dia galera, estou tentando criar um sistema onde o cliente informará CNPJ e senha no formulário, depois que validar, exibirá todos os documentos contendo esse CNPJ.
O erro é, quando faço o login buscando o CNPJ, não esta exibindo os documentos. Poderiam me ajudar?
index.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title> Teste </title>
<link rel="stylesheet" href="css.css"/>
</head>
<body>
<div id="conteudo">
<div id="logo">
<img src="img/LOGO-PORTALESCRITORIOS.png" alt="logo" style="position: relative; top: 5px; left: 280px;"/>
</div>
<div id="login">
<form method="post" action="valida.php" style="position: relative; top: 40px;">
<span class="logintxt" style="padding-left: 70px;"> Informe seu CNPJ: </span>
<br/>
<input type="text" name="clicnpj" maxlength="14" size="30" class="input" style="position: relative; left: 70px; height: 25px;"/>
<br/><br/>
<span class="logintxt" style="padding-left: 70px;"> Informe sua senha: </span>
<br/>
<input type="password" name="senha" maxlength="14" size="30" class="input" style="position: relative; left: 70px; height: 25px;"/>
<br/><br/>
<input type="submit" value="Entrar" class="input" style="position: relative; left: 70px;"/>
</form>
</div>
</div>
<div id="rodape">
<center><a href=""><img src="" alt="" border="0"/></a></center>
</div>
</body>
</html>
valida.php
<?php
$clicnpj= $_POST["clicnpj"];
$senha1 = $_POST["senha"];
$senha = md5($senha1);
$sql = "SELECT cnpjcliente, senha FROM cadclientes WHERE cnpjcliente='$clicnpj' and senha='$senha'";
$conexao = mysql_connect("localhost", "root", "pass") or
die(mens(0));
$db = mysql_select_db("root",$conexao) or
exit(mens(1));
$sql = mysql_query($sql) or
die ("Houve um erro na gravacao dos dados. Por favor, clique em voltar e verifique se os campos obrigatorios estao preenchidos.");
$num_linha = mysql_num_rows($sql);
if ($num_linha > 0) {
session_start();
$_SESSION['usuario'] = $clicnpj;
header("Location: teste.html");
}
else {
echo "<br><b><br><h4 align='center'><font face='Arial'>CNPJ/CPF ou senha inválido.</font></h4>";
echo "<br><br><center><a href=index.php>Clique aqui e volte à tela de login.</a>";
}
?>
listar_arquivos.php
<?php
session_start();
if ( !session_is_registered('usuario')) {
header("Location: listar_arquivos.php");
}
require("dbconnect.inc.php");
$qry = "SELECT id, cnpjescritorio, cnpjcliente, mes, ano, nomerelatorio, tipo FROM documentos WHERE cnpjcliente='&clicnpj'";
$res = mysql_query($qry);
while($fila = mysql_fetch_array($res))
{
print "$fila[nomerelatorio]
<table>
<tr>
<td>$fila[nomerelatorio]</td>
<td >($fila[tipo])</td>
<td ><a href='baixar_arquivo.php'>Fazer Download</a></td>
</tr>
</table>
<br>
<br>";
}
?>
Desde já, muito obrigado.
Carregando comentários...