0
I am developing a Process Registration system for the City Hall of my city and came to me a question.
Is it possible, after recording the data, to edit only once the data? Only one, after that is "undeditable".
Follow the editing code if anyone has any ideas!
<?php
require 'conexao.php';
// Recebe o id do cliente do cliente via GET
$id_cliente = (isset($_GET['id'])) ? $_GET['id'] : '';
// Valida se existe um id e se ele é numérico
if (!empty($id_cliente) && is_numeric($id_cliente)):
// Captura os dados do cliente solicitado
$conexao = conexao::getInstance();
$sql = 'SELECT id, numero, nome, status, setor1, setor2, data1, observ1, setor3, setor4, data2, observ2, setor5, setor6, data3, observ3 FROM processos WHERE id = :id';
$stm = $conexao->prepare($sql);
$stm->bindValue(':id', $id_cliente);
$stm->execute();
$cliente = $stm->fetch(PDO::FETCH_OBJ);
endif;
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Edição de Processo</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/custom.css">
<style type="text/css">
<!--
body {
background-image: url("./img/bg.jpg");
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center;
background-size: cover;
}
<!---->
</style>
</head>
<body>
<div class='container'>
<fieldset>
<legend><h1>Formulário - Edição de Processo</h1></legend>
<?php if(empty($cliente)):?>
<h3 class="text-center text-danger">Processo não encontrado!</h3>
<?php else: ?>
<form action="all_processo.php" method="post" id='form-contato' enctype='multipart/form-data'>
<div class="row">
<p><div class='form-group'>
<label for='numero'>Número do Processo</label>
<input type='number' class='form-control' id='numero' name='numero' value="<?=$cliente->numero?>" placeholder='Informe o Número do Processo'>
<span class='msg-erro msg-numero'></span>
</div></p>
<p><div class="form-group">
<label for="nome">Nome do Processo</label>
<input type="text" class="form-control" id="nome" name="nome" value="<?=$cliente->nome?>" placeholder="Informe o Nome">
<span class='msg-erro msg-nome'></span>
</div></p>
<p><div class="form-group">
<label for="status">Status do Processo</label>
<select class="form-control" name="status" id="status">
<option value="<?=$cliente->status?>"><?=$cliente->status?></option>
<option value="Ativo">Ativo</option>
<option value="Inativo">Inativo</option>
</select>
<span class='msg-erro msg-status'></span>
</div></p>
<p><div class="form-group">
<label for="setor">Setor 1</label>
<input type="text" value="<?=$cliente->setor1?>" class="form-control" id="setor1" name="setor1" placeholder="Informe o Setor Inicial"> Setor 2 <input type="text" value="<?=$cliente->setor2?>" class="form-control" id="setor2" name="setor2" placeholder=" Informe o Setor Final">
<p><label for="data1">Data:</label>
<input type="date" name="data1" id="data1" value="<?=$cliente->data1?>" /></p>
<p><label><p>Observações</p></label>
<textarea name="observ1" id='observ1' rows="6" cols="50" placeholder="Informe as observações sobre o processo"><?=$cliente->observ1?></textarea></P>
<span class='msg-erro msg-setor'></span></div>
<p><div class="form-group">
<label for="setor">Setor 3</label>
<input type="text" value="<?=$cliente->setor3?>" class="form-control" id="setor3" name="setor3" placeholder="Informe o Setor Inicial"> Setor 4 <input type="text" value="<?=$cliente->setor4?>" class="form-control" id="setor4" name="setor4" placeholder=" Informe o Setor Final">
<p><label for="data2">Data:</label>
<input type="date" name="data2" id="data2" value="<?=$cliente->data2?>" /></p>
<p><label><p>Observações</p></label>
<textarea name="observ2" id='observ2' rows="6" cols="50" placeholder="Informe as observações sobre o processo"><?=$cliente->observ2?></textarea></P>
<span class='msg-erro msg-setor'></span></div>
<p><div class="form-group">
<label for="setor">Setor 5</label>
<input type="text" value="<?=$cliente->setor5?>" class="form-control" id="setor5" name="setor5" placeholder="Informe o Setor Inicial"> Setor 6 <input type="text" value="<?=$cliente->setor6?>" class="form-control" id="setor6" name="setor6" placeholder=" Informe o Setor Final">
<p><label for="data3">Data:</label>
<input type="date" name="data3" id="data3" value="<?=$cliente->data3?>" /></p>
<p><label><p>Observações</p></label>
<textarea name="observ3" id='observ3' rows="6" cols="50" placeholder="Informe as observações sobre o processo"><?=$cliente->observ3?></textarea></P>
<span class='msg-erro msg-setor'></span></div>
<input type="hidden" name="acao" value="editar">
<input type="hidden" name="id" value="<?=$cliente->id?>">
<p> <button type="submit" class="btn btn-primary" id='botao'>
Salvar
</button></p>
<a href='listarprocessos.php' class="btn btn-danger">Cancelar</a>
</form>
<?php endif; ?>
</fieldset>
</div>
<script type="text/javascript" src="js/custom.js"></script>
</body>
</html>
Thanks in advance!
When you make 1 edit set the number 1 in the database, when the person tries to edit again, check if the number 1 is already set. If it is not possible, if 0 is still possible. Just like @David Alves said.
– WSS