feliper 0 Denunciar post Postado Janeiro 18, 2016 Pessoal, já estou uma hora procurando o erro e não encontro, será que podem me ajudar, toda vez que faço update do nome/senha o email e telefone somem. Segue o codigo: <?php // A sessão precisa ser iniciada em cada página diferente if (!isset($_SESSION)) session_start(); // Verifica se não há a variável da sessão que identifica o usuário if (!isset($_SESSION['UsuarioID'])) { // Destrói a sessão por segurança session_destroy(); // Redireciona o visitante de volta pro login header("Location: index.php?msg=2"); exit; } $id = $_SESSION['UsuarioID']; if ($_SESSION['UsuarioNivel'] == 1) { require ('conexao.php'); $nome = $_POST['nome']; $usuario = $_POST['usuario']; $senha = $_POST['senha']; $email = $_POST['email']; $telefone = $_POST['telefone']; $nivel = $_POST['nivel']; $ativo = $_POST['ativo']; $profissao = $_POST['profissao']; $sobre = $_POST['sobre']; $site = $_POST['site']; $twitter = $_POST['twitter']; $facebook = $_POST['facebook']; $comando = $_GET['comando']; $nova_senha = sha1($senha); isset($nome); if($nome==TRUE) { $executa = "`nome` = '$nome'"; isset($usuario); if($usuario==TRUE) { $executa = "`nome` = '$nome', `usuario` = '$usuario'"; } isset($senha); if($senha==TRUE) { $executa = "`nome` = '$nome', `usuario` = '$usuario', `senha` = '$nova_senha'"; } isset($email); if($email==TRUE) { $executa = "`nome` = '$nome', `usuario` = '$usuario', `senha` = '$nova_senha', `email` = '$email'"; } isset($telefone); if($telefone==TRUE) { $executa = "`nome` = '$nome', `usuario` = '$usuario', `senha` = '$nova_senha', `email` = '$email', `telefone` = '$telefone'"; } isset($nivel); if($nivel==TRUE) { $executa = "`nome` = '$nome', `usuario` = '$usuario', `senha` = '$nova_senha', `email` = '$email', `telefone` = '$telefone', `nivel` = '$nivel'"; } isset($ativo); if($ativo==TRUE) { $executa = "`nome` = '$nome', `usuario` = '$usuario', `senha` = '$nova_senha', `email` = '$email', `telefone` = '$telefone', `nivel` = '$nivel', `ativo` = '$ativo'"; } isset($profissao); if($profissao==TRUE) { $executa = "`nome` = '$nome', `usuario` = '$usuario', `senha` = '$nova_senha', `email` = '$email', `telefone` = '$telefone', `nivel` = '$nivel', `ativo` = '$ativo', `profissao` = '$profissao'"; } isset($sobre); if($sobre==TRUE) { $executa = "`nome` = '$nome', `usuario` = '$usuario', `senha` = '$nova_senha', `email` = '$email', `telefone` = '$telefone', `nivel` = '$nivel', `ativo` = '$ativo', `profissao` = '$profissao', `sobre` = '$sobre'"; } isset($site); if($site==TRUE) { $executa = "`nome` = '$nome', `usuario` = '$usuario', `senha` = '$nova_senha', `email` = '$email', `telefone` = '$telefone', `nivel` = '$nivel', `ativo` = '$ativo', `profissao` = '$profissao', `sobre` = '$sobre', `site` = '$site'"; } isset($twitter); if($twitter==TRUE) { $executa = "`nome` = '$nome', `usuario` = '$usuario', `senha` = '$nova_senha', `email` = '$email', `telefone` = '$telefone', `nivel` = '$nivel', `ativo` = '$ativo', `profissao` = '$profissao', `sobre` = '$sobre', `site` = '$site', `twitter` = '$twitter'"; } isset($facebook); if($facebook==TRUE) { $executa = "`nome` = '$nome', `usuario` = '$usuario', `senha` = '$nova_senha', `email` = '$email', `telefone` = '$telefone', `nivel` = '$nivel', `ativo` = '$ativo', `profissao` = '$profissao', `sobre` = '$sobre', `site` = '$site', `twitter` = '$twitter', `facebook` = '$facebook'"; } } else { isset($usuario); if($usuario==TRUE) { $executa = "`usuario` = '$usuario'"; isset($senha); if($senha==TRUE) { $executa = "`usuario` = '$usuario', `senha` = '$nova_senha'"; } isset($email); if($email==TRUE) { $executa = "`usuario` = '$usuario', `senha` = '$nova_senha', `email` = '$email'"; } isset($telefone); if($telefone==TRUE) { $executa = "`usuario` = '$usuario', `senha` = '$nova_senha', `email` = '$email', `telefone` = '$telefone'"; } isset($nivel); if($nivel==TRUE) { $executa = "`usuario` = '$usuario', `senha` = '$nova_senha', `email` = '$email', `telefone` = '$telefone', `nivel` = '$nivel'"; } isset($ativo); if($ativo==TRUE) { $executa = "`usuario` = '$usuario', `senha` = '$nova_senha', `email` = '$email', `telefone` = '$telefone', `nivel` = '$nivel', `ativo` = '$ativo'"; } isset($profissao); if($profissao==TRUE) { $executa = "`usuario` = '$usuario', `senha` = '$nova_senha', `email` = '$email', `telefone` = '$telefone', `nivel` = '$nivel', `ativo` = '$ativo', `profissao` = '$profissao'"; } isset($sobre); if($sobre==TRUE) { $executa = "`usuario` = '$usuario', `senha` = '$nova_senha', `email` = '$email', `telefone` = '$telefone', `nivel` = '$nivel', `ativo` = '$ativo', `profissao` = '$profissao', `sobre` = '$sobre'"; } isset($site); if($site==TRUE) { $executa = "`usuario` = '$usuario', `senha` = '$nova_senha', `email` = '$email', `telefone` = '$telefone', `nivel` = '$nivel', `ativo` = '$ativo', `profissao` = '$profissao', `sobre` = '$sobre', `site` = '$site'"; } isset($twitter); if($twitter==TRUE) { $executa = "`usuario` = '$usuario', `senha` = '$nova_senha', `email` = '$email', `telefone` = '$telefone', `nivel` = '$nivel', `ativo` = '$ativo', `profissao` = '$profissao', `sobre` = '$sobre', `site` = '$site', `twitter` = '$twitter'"; } isset($facebook); if($facebook==TRUE) { $executa = "`usuario` = '$usuario', `senha` = '$nova_senha', `email` = '$email', `telefone` = '$telefone', `nivel` = '$nivel', `ativo` = '$ativo', `profissao` = '$profissao', `sobre` = '$sobre', `site` = '$site', `twitter` = '$twitter', `facebook` = '$facebook'"; } } else { isset($senha); if($senha==TRUE) { $executa = "`senha` = '$nova_senha'"; isset($email); if($email==TRUE) { $executa = "`senha` = '$nova_senha', `email` = '$email'"; } isset($telefone); if($telefone==TRUE) { $executa = "`senha` = '$nova_senha', `email` = '$email', `telefone` = '$telefone'"; } isset($nivel); if($nivel==TRUE) { $executa = "`senha` = '$nova_senha', `email` = '$email', `telefone` = '$telefone', `nivel` = '$nivel'"; } isset($ativo); if($ativo==TRUE) { $executa = "`senha` = '$nova_senha', `email` = '$email', `telefone` = '$telefone', `nivel` = '$nivel', `ativo` = '$ativo'"; } isset($profissao); if($profissao==TRUE) { $executa = "`senha` = '$nova_senha', `email` = '$email', `telefone` = '$telefone', `nivel` = '$nivel', `ativo` = '$ativo', `profissao` = '$profissao'"; } isset($sobre); if($sobre==TRUE) { $executa = "`senha` = '$nova_senha', `email` = '$email', `telefone` = '$telefone', `nivel` = '$nivel', `ativo` = '$ativo', `profissao` = '$profissao', `sobre` = '$sobre'"; } isset($site); if($site==TRUE) { $executa = "`senha` = '$nova_senha', `email` = '$email', `telefone` = '$telefone', `nivel` = '$nivel', `ativo` = '$ativo', `profissao` = '$profissao', `sobre` = '$sobre', `site` = '$site'"; } isset($twitter); if($twitter==TRUE) { $executa = "`senha` = '$nova_senha', `email` = '$email', `telefone` = '$telefone', `nivel` = '$nivel', `ativo` = '$ativo', `profissao` = '$profissao', `sobre` = '$sobre', `site` = '$site', `twitter` = '$twitter'"; } isset($facebook); if($facebook==TRUE) { $executa = "`senha` = '$nova_senha', `email` = '$email', `telefone` = '$telefone', `nivel` = '$nivel', `ativo` = '$ativo', `profissao` = '$profissao', `sobre` = '$sobre', `site` = '$site', `twitter` = '$twitter', `facebook` = '$facebook'"; } } else { isset($email); if($email==TRUE) { $executa = "`email` = '$email'"; isset($telefone); if($telefone==TRUE) { $executa = "`email` = '$email', `telefone` = '$telefone'"; } isset($nivel); if($nivel==TRUE) { $executa = "`email` = '$email', `telefone` = '$telefone', `nivel` = '$nivel'"; } isset($ativo); if($ativo==TRUE) { $executa = "`email` = '$email', `telefone` = '$telefone', `nivel` = '$nivel', `ativo` = '$ativo'"; } isset($profissao); if($profissao==TRUE) { $executa = "`email` = '$email', `telefone` = '$telefone', `nivel` = '$nivel', `ativo` = '$ativo', `profissao` = '$profissao'"; } isset($sobre); if($sobre==TRUE) { $executa = "`email` = '$email', `telefone` = '$telefone', `nivel` = '$nivel', `ativo` = '$ativo', `profissao` = '$profissao', `sobre` = '$sobre'"; } isset($site); if($site==TRUE) { $executa = "`email` = '$email', `telefone` = '$telefone', `nivel` = '$nivel', `ativo` = '$ativo', `profissao` = '$profissao', `sobre` = '$sobre', `site` = '$site'"; } isset($twitter); if($twitter==TRUE) { $executa = "`email` = '$email', `telefone` = '$telefone', `nivel` = '$nivel', `ativo` = '$ativo', `profissao` = '$profissao', `sobre` = '$sobre', `site` = '$site', `twitter` = '$twitter'"; } isset($facebook); if($facebook==TRUE) { $executa = "`email` = '$email', `telefone` = '$telefone', `nivel` = '$nivel', `ativo` = '$ativo', `profissao` = '$profissao', `sobre` = '$sobre', `site` = '$site', `twitter` = '$twitter', `facebook` = '$facebook'"; } } else { isset($telefone); if($telefone==TRUE) { $executa = "`telefone` = '$telefone'"; isset($nivel); if($nivel==TRUE) { $executa = "`telefone` = '$telefone', `nivel` = '$nivel'"; } isset($ativo); if($ativo==TRUE) { $executa = "`telefone` = '$telefone', `nivel` = '$nivel', `ativo` = '$ativo'"; } isset($profissao); if($profissao==TRUE) { $executa = "`telefone` = '$telefone', `nivel` = '$nivel', `ativo` = '$ativo', `profissao` = '$profissao'"; } isset($sobre); if($sobre==TRUE) { $executa = "`telefone` = '$telefone', `nivel` = '$nivel', `ativo` = '$ativo', `profissao` = '$profissao', `sobre` = '$sobre'"; } isset($site); if($site==TRUE) { $executa = "`telefone` = '$telefone', `nivel` = '$nivel', `ativo` = '$ativo', `profissao` = '$profissao', `sobre` = '$sobre', `site` = '$site'"; } isset($twitter); if($twitter==TRUE) { $executa = "`telefone` = '$telefone', `nivel` = '$nivel', `ativo` = '$ativo', `profissao` = '$profissao', `sobre` = '$sobre', `site` = '$site', `twitter` = '$twitter'"; } isset($facebook); if($facebook==TRUE) { $executa = "`telefone` = '$telefone', `nivel` = '$nivel', `ativo` = '$ativo', `profissao` = '$profissao', `sobre` = '$sobre', `site` = '$site', `twitter` = '$twitter', `facebook` = '$facebook'"; } } else { isset($nivel); if($nivel==TRUE) { $executa = "`nivel` = '$nivel'"; isset($ativo); if($ativo==TRUE) { $executa = "`nivel` = '$nivel', `ativo` = '$ativo'"; } isset($profissao); if($profissao==TRUE) { $executa = "`nivel` = '$nivel', `ativo` = '$ativo', `profissao` = '$profissao'"; } isset($sobre); if($sobre==TRUE) { $executa = "`nivel` = '$nivel', `ativo` = '$ativo', `profissao` = '$profissao', `sobre` = '$sobre'"; } isset($site); if($site==TRUE) { $executa = "`nivel` = '$nivel', `ativo` = '$ativo', `profissao` = '$profissao', `sobre` = '$sobre', `site` = '$site'"; } isset($twitter); if($twitter==TRUE) { $executa = "`nivel` = '$nivel', `ativo` = '$ativo', `profissao` = '$profissao', `sobre` = '$sobre', `site` = '$site', `twitter` = '$twitter'"; } isset($facebook); if($facebook==TRUE) { $executa = "`nivel` = '$nivel', `ativo` = '$ativo', `profissao` = '$profissao', `sobre` = '$sobre', `site` = '$site', `twitter` = '$twitter', `facebook` = '$facebook'"; } } else { isset($ativo); if($ativo==TRUE) { $executa = "`ativo` = '$ativo'"; isset($profissao); if($profissao==TRUE) { $executa = "`ativo` = '$ativo', `profissao` = '$profissao'"; } isset($sobre); if($sobre==TRUE) { $executa = "`ativo` = '$ativo', `profissao` = '$profissao', `sobre` = '$sobre'"; } isset($site); if($site==TRUE) { $executa = "`ativo` = '$ativo', `profissao` = '$profissao', `sobre` = '$sobre', `site` = '$site'"; } isset($twitter); if($twitter==TRUE) { $executa = "`ativo` = '$ativo', `profissao` = '$profissao', `sobre` = '$sobre', `site` = '$site', `twitter` = '$twitter'"; } isset($facebook); if($facebook==TRUE) { $executa = "`ativo` = '$ativo', `profissao` = '$profissao', `sobre` = '$sobre', `site` = '$site', `twitter` = '$twitter', `facebook` = '$facebook'"; } } else { isset($profissao); if($profissao==TRUE) { $executa = "`profissao` = '$profissao'"; isset($sobre); if($sobre==TRUE) { $executa = "`profissao` = '$profissao', `sobre` = '$sobre'"; } isset($site); if($site==TRUE) { $executa = "`profissao` = '$profissao', `sobre` = '$sobre', `site` = '$site'"; } isset($twitter); if($twitter==TRUE) { $executa = "`profissao` = '$profissao', `sobre` = '$sobre', `site` = '$site', `twitter` = '$twitter'"; } isset($facebook); if($facebook==TRUE) { $executa = "`profissao` = '$profissao', `sobre` = '$sobre', `site` = '$site', `twitter` = '$twitter', `facebook` = '$facebook'"; } } else { isset($sobre); if($sobre==TRUE) { $executa = "`sobre` = '$sobre'"; isset($site); if($site==TRUE) { $executa = "`sobre` = '$sobre', `site` = '$site'"; } isset($twitter); if($twitter==TRUE) { $executa = "`sobre` = '$sobre', `site` = '$site', `twitter` = '$twitter'"; } isset($facebook); if($facebook==TRUE) { $executa = "`sobre` = '$sobre', `site` = '$site', `twitter` = '$twitter', `facebook` = '$facebook'"; } } else { isset($site); if($site==TRUE) { $executa = "`site` = '$site'"; isset($twitter); if($twitter==TRUE) { $executa = "`site` = '$site', `twitter` = '$twitter'"; } isset($facebook); if($facebook==TRUE) { $executa = "`site` = '$site', `twitter` = '$twitter', `facebook` = '$facebook'"; } } else { isset($twitter); if($twitter==TRUE) { $executa = "`twitter` = '$twitter'"; isset($facebook); if($facebook==TRUE) { $executa = "`twitter` = '$twitter', `facebook` = '$facebook'"; } } else { isset($facebook); if($facebook==TRUE) { $executa = "`facebook` = '$facebook'"; } } } } } } } } } } } } // query dados do usuário $update_dados = "UPDATE `usuarios` SET $executa WHERE `id` = '$comando'"; mysql_query($update_dados); header("Location: editar.usuario.php?id=$id&comando=$comando&msg=2"); } else { header("Location: index.php?msg=7"); } ?> Compartilhar este post Link para o post Compartilhar em outros sites
BlackMix 15 Denunciar post Postado Janeiro 18, 2016 Seria muito bom você mudar seu modo de programar :huh: Não precisaria desses IFs todos aí, faça uma função de validar, Mysql está obsoleto na Nova versão do php e exibe erros na versões 5.6 use ini_set('display_errors', true); error_reporting(E_ALL); para exibir algum erro.. e por que você não manda o id via POST aqui ? $comando = $_GET['comando']; Compartilhar este post Link para o post Compartilhar em outros sites
kelvim 11 Denunciar post Postado Janeiro 18, 2016 Concordo com isso. Seria muito bom você mudar seu modo de programar :huh: Não precisaria desses IFs todos aí, faça uma função de validar, essas condições estão no minimo estranhas para mim: isset($facebook); if($facebook==TRUE) deveria ser algo assim: if(isset($facebook)) Dito isso, com essa estrutura complexa sua, o que se pode fazer é ir colocando echo dentro de algumas condições dessas e ir vendo onde ele entra, quais os dados está trazendo para debugar e achar o erro. Compartilhar este post Link para o post Compartilhar em outros sites