Ir para conteúdo
Fórum Script Brasil
  • 0

(Resolvido) Sistema de login.


Diego Vieira

Pergunta

Primeiramente boa tarde,

Bom pessoal tenho o seguinte arquivo "editar.php" esse editar php tem como função editar as váriaveis que se encontra em tal arquivo.

Mas ao clicar em OK nada acontece, irei postar o código para vocês verem.

<?
include "protect.php";
include "config.inc.php";
if (!file_exists("usuarios/$nome2.php") && $nome2 != ""): # SALVA O NOME NOVO NO COOKIE DO NOME SE O USUARIO TROCAR DE NOME, PARA O INCLUDE DAR CERTO
setcookie("llbra_nome",$nome2,time()+3600*$tempo);
endif;
$nome = $_COOKIE['llbra_nome'];
include "usuarios/$nome.php";
?>
<?
include "protect.php";
include "config.inc.php";
if (!file_exists("usuarios/$nome2.php") && $nome2 != ""): # SALVA O NOME NOVO NO COOKIE DO NOME SE O USUARIO TROCAR DE NOME, PARA O INCLUDE DAR CERTO
setcookie("llbra_nome",$nome2,time()+3600*$tempo);
endif;
$nome = $_COOKIE['llbra_nome'];
include "usuarios/$nome.php";
?>
<?
if ($acao == "editar"):

$fake = htmlspecialchars(trim($_POST['admin'])); // para seguranca - detalhes no 'admin.php'

$erro = "";
# PEGANDO AS VARIAVEIS // htmscpecialchars() -> remove tags html no codigo // trim() -> remove espacos duplos
$nome2 = htmlspecialchars(trim($_POST['nome2']));
$email2 = htmlspecialchars(trim($_POST['email2']));
$senha2 = htmlspecialchars(trim($_POST['senha2']));
$nomeC2 = htmlspecialchars(trim($_POST['nomeC2']));
$cidade2 = htmlspecialchars(trim($_POST['cidade2']));
$avatar2 = htmlspecialchars(trim($_POST['avatar2']));

# VERIFICA&Ccedil;&Atilde;O DE TAMANHO
if (strlen($nome2) > $len_nome || strlen($email2) > $len_mail || strlen($senha2) > $len_pass
|| strlen($nomeC2) > $len_nomeC || strlen($cidade2) > $len_cidade):

$erro .= "<center>Algum campo excedeu o tamanho limite.</center><br><br>";
endif;

if ($nome != "$nome2" && file_exists("usuarios/$nome2.php")):

$erro .= "<center>J&aacute; existe um usu&aacute;rio com esse Login.</center><br><br>";
endif;

if ($erro != ""):

echo "<br><center><h1>Os seguintes erros foram encontrados:</h1></center>";
echo $erro;

else:

$fileMessage = "<?\n";

if ($nomeC2 == ""):
$fileMessage .="\$nomeC = \"$nomeC\";\n";
else:
$fileMessage .="\$nomeC = \"$nomeC2\";\n";
endif;

if ($cidade2 == ""):
$fileMessage .="\$cidade = \"$cidade\";\n";
else:
$fileMessage .="\$cidade = \"$cidade2\";\n";
endif;

if ($email2 == ""):
$fileMessage .="\$email = \"$email\";\n";
else:
$fileMessage .="\$email = \"$email2\";\n";
endif;

if ($nome2 == ""):
$fileMessage .="\$nome = \"$nome\";\n";
else:
$fileMessage .="\$nome = \"$nome2\";\n";
endif;

if ($senha2 == ""):
$fileMessage .="\$senha = \"$senha\";\n";
else:
$nova_senha = crypt($senha2, "salt");
$fileMessage .="\$senha = \"$nova_senha\";\n";
endif;

if ($admin != ""):
$fileMessage .="\$admin = \"$admin\";\n";
else:
endif;
if ($avatar == ""):
$fileMessage .="$avatar = \"$avatar\";\n";
else:
$fileMessage .="\$avatar = \"$avatar2\";\n";
endif;

$fileMessage .="?>";

if ($nome2 != ""):
unlink("usuarios/$nome.php");

$fp = fopen("usuarios/$nome2.php","w");
fputs($fp,$fileMessage);
fclose($fp);
else:
$fp = fopen("usuarios/$nome.php","w");
fputs($fp,$fileMessage);
fclose($fp);
endif;



echo "<center>Dados editados com Sucesso!</center>";
exit;
endif;endif;
?>
<html><head><title>Logado no <?=$nome_site?></title>
<link href="style.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
a:link {
color: #FF0000;
text-decoration: none;
}
a:visited {
color: #FF0000;
text-decoration: none;
}
a:hover {
color: #0000FF;
text-decoration: none;
}
a:active {
color: #000000;
text-decoration: none;
}
.style3 {color: #FF0000}
.style4 {color: #00FF00}
body,td,th {
color: #FFFFFF;
font-weight: bold;
}
body {
background-color: #000000;
}
.style5 {font-size: 7pt}
-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>

<body>
<p>
</p>
<form method="post" action="editar.php">
<p align="left">
<input type="hidden" name="acao" value="editar">
Deixe em branco os campos abaixo que n&atilde;o quiser alterar.<br>
<br>
Alterar Nome: &nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;
<input type="text" name="nomeC2" size="20" maxlength="50" value="">
<br>
<span class="style4">Atual : <b><? echo "$nomeC"; ?></b></span><br>
<br>
Alterar Cidade:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp; &nbsp;
<input type="text" name="cidade2" size="20" maxlength="30" value="">
<br>
<span class="style4"><b> Atual : <? echo "$cidade"; ?></b></span><br>
<br>
Alterar E-mail:&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;
&nbsp;&nbsp;
<input type="text" name="email2" size="20" maxlength="30" value="">
<br>
<span class="style4">Atual : <? echo "$email"; ?></span><br>
<br>
Alterar Login:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" name="nome2" size="20" maxlength="20" value="">
<br>
<span class="style4">Atual : <? echo "$nome"; ?></span><br>
<br>
Alterar Senha:

&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;
<input type="password" name="nova_senha" size="20" maxlength="20" value="">
<br>
</p>
<div align="center">Alterar Avatar<br>
<span class="style5">( <span class="style3">Copie o nome do arquivo gerado pelo upload e cole depois do &quot;avatar/&quot; Exemplo: avatar/teste.jpg, Recomendamos foto tamanho <span class="style4">114px</span> por <span class="style4">104px</span> </span> ) <br>
<input type="text" name="$avatar2" size="30" maxlength="999" value="avatar/">
</span><br>
<br>
</div>
<div id="avatar" style="height:114px; width:104px; margin-left:auto; margin-right:auto;">
<div align="center"><img src="<? echo "$avatar"; ?>" name="$nome" width="103" height="114" border="1" id="$nome" /><a href="foto.php">Enviar Foto </a></div>
</div>
<div align="center"><br>
<br>
<input name="submit" type="submit" value="OK">
</div>
</form>
</body>
</html>
<?
if ($acao == descadastrar)
{
$apagar = $nome;
$apagar .= ".php";
unlink ("usuarios/$apagar");
echo "<center>Usuário deletado!</center>
&lt;script>window.location='deslogar.php'</script>";
}
?>
[/codebox]

Bom espero que em ajudem. Eu to aprendendo php então por favor pega leve comigo, eu fiz o sistema mas sempre me escapa algo xD. Obrigado a todos.

Editado por Jonathan Queiroz
Remover palavra "Ajuda" do título do tópico (Jonathan)
Link para o comentário
Compartilhar em outros sites

2 respostass a esta questão

Posts Recomendados

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,1k
    • Posts
      651,8k
×
×
  • Criar Novo...