Variavel vindo vazias
Bom dia a todos, gostaria que minhas variáveis não vinhece vazias, ja tentei colocar o isset e o empty, mais mesmo assim eles gravam no banco vazia, me ajudem ai
codigo:
<?php
//criar a conexão com o banco
include ("../modulos/config.php");
if(trim(isset($_POST['done']))){
/* echo "<script type='text/javascript'> alert('Todos os campos devem ser preenchidos');</script>";*/
$nome = trim($_POST['nome']);
$usuario = trim($_POST['usuario']);
$senha = trim($_POST['senha']);
$email = trim($_POST['email']);
$sql = mysql_query("INSERT INTO usuario (`nome`, `user`,`senha`, `email`, `data`) VALUES ('$nome', '$usuario', '$senha', '$email', NOW())") or die(mysql_error());
if($sql){
$erro = "Usuário cadastrado com sucesso!";
} else{
$erro = "Não foi possivel cadastrar o usuário";
}
}
?>
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="utf-8">
<title>Painel Administrativo</title>
<!--CSS-->
<link href="../../css/style.css" rel="stylesheet" type="text/css">
<!--***CSS***----->
</head>
<body>
<?php include ("../modulos/topo.php");?>
<div id="conteudo">
<?php include ("../modulos/conteudo.php");?>
<div id="resultado">
<div id="tituloUser"><h3 align="center">Usuários Administradores</h3></div><!--TITULOUSER-->
<?php $select = mysql_query("SELECT * FROM usuario WHERE `status` = 1") or die(mysql_error());
?>
<table id="table">
<tr>
<th id="th">Nome</th>
<th id="th">Login</th>
<th id="th">E-mail</th>
<th id="th">Status</th>
<th id="th">Ações</th>
</tr>
<?php
while($linha = mysql_fetch_assoc($select)){
$id = $linha['id'];
$nome = $linha['nome'];
$login = $linha['user'];
$email = $linha['email'];
$status = $linha['status'];
?>
<tr>
<td id="td"><?php echo $nome ?></td>
<td id="td"><?php echo $login ?></td>
<td id="td"><?php echo $email ?></td>
<td id="td"><?php echo $status ?></td>
<td id="td"><?php echo $nome ?></td>
</tr>
<?php } ?>
</table>
<br />
<br />
<div id="tituloUser"><h3 align="center">Novo Usuário</h3></div><!--TITULOUSER-->
<?phpif(isset($erro)){
print '<div style="width:80%; background:#ff6600; color:#fff; padding: 5px 0px 5px 0px; text-align:center; margin: 0 auto;">'.$erro.'</div>';
}
?>
<div id="cadUser">
<form action="home.php" method="post" enctype="multipart/form-data"><!-- DADOS PESSOAIS-->
<fieldset id="fieldset">
<legend>Dados</legend>
<table cellspacing="10">
<td>
<label for="nome">Nome: </label>
</td>
<td align="left">
<input name="nome" id="nome" type="text" />
</td>
<tr>
<td>
<label for="usuario">Usuario: </label>
</td>
<td align="left">
<input name="usuario" id="usuario" type="text" />
</td>
</tr>
<tr>
<td>
<label for="senha">Senha:</label>
</td>
<td align="left">
<input name="senha" id="senha" type="password" >
</td>
</tr>
<tr>
<td>
<label for="email">E-mail:</label>
</td>
<td align="left">
<input name="email" id="email" type="email" >
</td>
</tr>
</table>
</fieldset>
<br />
<input type="submit" value="Cadastrar"><input type="hidden" name="done" value="" />
<input type="reset" value="Limpar">
</form>
</div><!--CADUSER-->
</div><!--RESULTADO-->
</div><!--CONTEUDO-->
</body>
</html>Discussão (2)
Carregando comentários...