-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathform_noticia.php
98 lines (74 loc) · 3.07 KB
/
form_noticia.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php include("sc_login_comum.php"); ?>
<meta charset="utf-8"/>
<link rel="stylesheet" type="text/css" href="css/site.css">
<link rel="stylesheet" type="text/css" href="css/menuadm.css">
<link rel="stylesheet" type="text/css" href="css/form.css">
<link rel="stylesheet" type="text/css" href="css/buttons.css">
<link rel="stylesheet" type="text/css" href="css/tables.css">
<section id="index_adm">
<?php
$noti_id = filter_input(INPUT_GET,'noti_id',FILTER_SANITIZE_NUMBER_INT);
if(isset($noti_id))//Se for update
{
$consulta_sql = "SELECT noti_tit,
noti_txt,
noti_img,
DATE_FORMAT(noti_data, '%d/%m/%Y') as noti_data
FROM tb_noti WHERE noti_id = '$noti_id'";
require_once("DBConnection.php");
$result = mysqli_query($conn, $consulta_sql);
$registro = mysqli_fetch_array($result);
mysqli_close($conn);
}
?>
<form method="post" action="noti_crud.php" id="sem_margim_top" enctype="multipart/form-data">
<fieldset>
<?php if(isset($noti_id)) { ?>
<legend>Atualizar Noticia </legend>
<input type="hidden" name="noti_id" value="<?php echo isset($noti_id)? $noti_id : "";?>">
<?php }else{ ?>
<legend>Cadastrar Notícia </legend>
<?php }; ?>
<label>Título: </label>
<input type="text" name="noti_tit" value="<?php echo isset($noti_id)? $registro['noti_tit'] : "";?>">
<label>Data: </label>
<input type="text" name="noti_data" value="<?php echo isset($noti_id)? $registro['noti_data'] : "";?>">
<label>Texto: </label>
<textarea class="float_right" rows="9" cols="27" name="noti_txt"><?php echo isset($noti_id)? $registro['noti_txt'] : "";?></textarea>
<label>Atualizar
<input type="checkbox" name="noti_img" id="noti_img" onClick="habilitar();" value="<?php echo isset($noti_id)? $registro['noti_img'] : "";?>" <?php echo isset($noti_id)? "" : "checked";?>></label>
<label>Imagem: </label>
<input type="file" name="file" id="file" onChange="verImagem();">
<img src="<?php echo isset($noti_id)? $registro['noti_img'] : "/imagens/sem_foto.png";?>" id="imagem">
<div>
<a href="Administracao.php?pagina=noticiasCadastradas.php"><input type="button" value="Voltar"></a>
<input type="reset" value="Limpar">
<input type="submit" value="Salvar" name="Salvar">
</div>
</fieldset>
</form>
<script type="text/javascript">
function verImagem()//OnChange
{
var oFReader = new FileReader();
oFReader.readAsDataURL(document.getElementById("file").files[0]);
oFReader.onload = function (oFREvent)
{
document.getElementById("imagem").src = oFREvent.target.result;
};
};
function habilitar()//OnClick
{
if( document.getElementById('noti_img').checked )
{
document.getElementById('file').disabled = false; //habilita
}
else
{
document.getElementById("imagem").src = "<?php echo isset($noti_id) ? $_registro['noti_img'] : '/imagens/sem_foto.png' ?>";
document.getElementById('file').disabled = true;
//document.getElementById("name").innerHTML = "";
}
}
</script>
</section>