Mini Shell

Direktori : /home/emypro/www/admin/
Upload File :
Current File : /home/emypro/www/admin/users_edit.php

<?php include('header.php') ?>
<?php
$user = new User();

$flash = array();
// UPDATE
if(isset($_POST['action']) && $_POST['action'] == 'update'):
	unset($_POST['action']);

	$user_edit = $user->find($_GET['id']);

	if(strlen($_POST['name']) > 1 && strlen($_POST['email']) > 5):

		if(strlen($_POST['password']) >= 6):
			$_POST['password'] = Helper::hash($_POST['password']);
		else:
			$_POST['password'] = $user_edit->password;
		endif;

		if($user->update($_GET['id'], $_POST)):
			$flash = Helper::flash('success');
		else:
			$flash = Helper::flash('error');
		endif;

	else:
		$flash = Helper::flash('error');
	endif;
endif;

$user = $user->find($_GET['id']);
?>
<div id="page">
	<div class="row">
		<div class="col lg-12">
			<h2>Administradores / editar</h2>
		</div>
	</div>
	<div class="row">
		<?php if($flash): ?>
		<div class="col-lg-12">
			<div class="alert alert-<?= $flash['class'] ?> alert-dismissible">
				<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
				<?= $flash['message'] ?>
			</div>
		</div>
		<?php endif ?>
		<div class="col-lg-12">
			<a href="users.php" class="btn btn-primary">Voltar</a>
			<hr>
			<small>* todos os campos são obrigatórios</small><br>
			<small>* caso não deseje alterar a senha, deixar campo em branco</small>
			<form action="" method="post" enctype="multipart/form-data">
				<div class="form-group">
					<label for="name">Nome:</label>
					<input type="text" name="name" class="form-control" required value="<?= $user->name ?>">
				</div>
				<div class="form-group">
					<label for="email">E-mail:</label>
					<input type="email" name="email" class="form-control" required value="<?= $user->email ?>">
				</div>
				<div class="form-group">
					<label for="password">Senha: <small>(tamanho mínimo 6 caracteres)</small></label>
					<input type="password" name="password" class="form-control">
				</div>
				<div class="form-group">
					<input type="hidden" name="action" value="update">
					<button type="submit" class="btn btn-primary">Atualizar</button>
				</div>
			</form>
		</div>
	</div>
</div>

<?php include('footer.php') ?>

Zerion Mini Shell 1.0