Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
e ai rapaziada...
tenho um sistema de cadastro de usuário, e na parte de edição/Alteração do usuário mostro os dados dele,
nome:
usuario:
email:
senha atual:
nova senha:
meu problema é o seguinte: quando o usuário não informar uma nova senha, quero que a atual seja mantida...
só que não consigo fazer isso, não dá nenhum erro, mas também não funciona...
meu script
<?php
require_once("validaSessao.php");
require_once("config.php");
?>
<!doctype html>
<html lang="pt-br">
<head>
<title>Usuários Cadastrados</title>
<meta charset="utf-8">
<link rel="stylesheet" href="css/estilo.css" type="text/css" media="screen" />
</head>
<body>
<section id="ExibeUsu">
<h1>Usuários Cadastrados</h1>
<table>
<tr><th>Nome</th><th>Usuário</th><th>Email</th><th>Alterar | Excluir</th></tr>
<?php
$sqlExibe = mysql_query('SELECT * FROM ' . TABELA . ' ORDER BY nomeUsu ASC') or die(mysql_error());
while ($i = mysql_fetch_array($sqlExibe)) {
$id = $i[0]; // id usuario
$nome = $i[1]; // nome usuario
$usuario = $i[2]; // usuario usuario
$email = $i[3]; // email usuario
echo '<tr>
<td>', $nome, '</td>
<td>', $usuario, '</td>
<td>', $email, '</td>
<td class="alinhaCentro">
<a href="exibeUsu.php?acao=editar&id=' . $id . '">
<img src="http://www.demus.org.pe/notihome/img/editar.gif" alt="" /></a>
<a href="exibeUsu.php?acao=excluir">
<img src="http://www.clicksti.com.br/favoritos/excluir_grande.gif" alt="" /></a></td></tr>';
}
?>
</table>
</section>
<br />
<hr />
<br />
<?php
if (isset($_GET['acao']) && $_GET['acao'] == 'editar') {
$id = $_GET['id'];
$sqlEditar = mysql_query('SELECT * FROM ' . TABELA . ' WHERE idUsu = ' . $id) or die(mysql_error());
while ($i = mysql_fetch_array($sqlEditar)) {
$nome = $i[1]; // nome usuario
$usuario = $i[2]; // nome usuario
$email = $i[3]; // nome usuario
$senha = $i[4]; // senha
}
if (isset($_POST['salvar'])) {
$idUp = $_GET['id'];
$nomeUp = $_POST['nome'];
$usuarioUp = $_POST['usuario'];
$emailUp = $_POST['email'];
$novaSenhaUp = $_POST['novaSenha'];
if (empty($nomeUp)) {
echo '<span class="erro">Digite seu nome!</span>';
} elseif (empty($usuarioUp)) {
echo '<span class="erro">Digite seu usuário!</span>';
} elseif (!filter_var($emailUp, FILTER_VALIDATE_EMAIL)) {
echo '<span class="erro">Digite um email válido!</span>';
} elseif (empty($novaSenhaUp)) {
$novaSenhaUp = $_POST['senhaAtual'];
} else {
$sqlAtualizar = mysql_query("UPDATE " . TABELA . " SET nomeUsu = '$nome', usuUsu = '$usuarioUp', emailUsu = '$emailUp', senhaUsu = '$novaSenhaUp' WHERE idUsu = '$idUp'") or die(mysql_error());
header("Location: exibeUsu.php");
}
}
?>
<section id="form">
<form action="" method="post">
<fieldset>
<legend>Editar Usuários</legend>
<label for="nome">
<span>Nome:</span>
<input type="text" name="nome" value="<?php echo $nome; ?>" />
</label>
<label for="usuario">
<span>Usuário:</span>
<input type="text" name="usuario" value="<?php echo $usuario; ?>" />
</label>
<label for="email">
<span>Email:</span>
<input type="text" name="email" value="<?php echo $email; ?>" />
</label>
<label for="novasenha">
<span>Senha Atual:</span>
<input type="text" name="" value="<?php echo $senha; ?>" disabled="disable" />
</label>
<label for="novaSenha">
<span>Nova Senha:</span>
<input type="password" name="novaSenha" />
</label>
<button name="salvar">Salvar</button>
</fieldset>
</form>
</section>
<?php
}
?>
</body>
</html>Carregando comentários...