first commit
This commit is contained in:
126
admin/evento_imagem.php
Executable file
126
admin/evento_imagem.php
Executable file
@@ -0,0 +1,126 @@
|
||||
<?php require_once('../Connections/conn_sustentabilidade.php'); ?>
|
||||
<?php include('acesso.php')?>
|
||||
<?php
|
||||
if (!function_exists("GetSQLValueString")) {
|
||||
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
|
||||
{
|
||||
if (PHP_VERSION < 6) {
|
||||
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
|
||||
}
|
||||
|
||||
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
|
||||
|
||||
switch ($theType) {
|
||||
case "text":
|
||||
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
|
||||
break;
|
||||
case "long":
|
||||
case "int":
|
||||
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
|
||||
break;
|
||||
case "double":
|
||||
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
|
||||
break;
|
||||
case "date":
|
||||
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
|
||||
break;
|
||||
case "defined":
|
||||
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
|
||||
break;
|
||||
}
|
||||
return $theValue;
|
||||
}
|
||||
}
|
||||
|
||||
$editFormAction = $_SERVER['PHP_SELF'];
|
||||
if (isset($_SERVER['QUERY_STRING'])) {
|
||||
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
|
||||
}
|
||||
|
||||
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form_evento_atualiza")) {
|
||||
$updateSQL = sprintf("UPDATE tbeventos SET imagem_evento=%s WHERE id_evento=%s",
|
||||
GetSQLValueString($_FILES['imagem_evento']['name'], "text"),
|
||||
GetSQLValueString($_POST['id_evento'], "int"));
|
||||
|
||||
mysql_select_db($database_conn_sustentabilidade, $conn_sustentabilidade);
|
||||
$Result1 = mysql_query($updateSQL, $conn_sustentabilidade) or die(mysql_error());
|
||||
|
||||
$updateGoTo = "index.php";
|
||||
if (isset($_SERVER['QUERY_STRING'])) {
|
||||
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
|
||||
$updateGoTo .= $_SERVER['QUERY_STRING'];
|
||||
}
|
||||
header(sprintf("Location: %s", $updateGoTo));
|
||||
}
|
||||
|
||||
$colname_atualiza_imagem = "-1";
|
||||
if (isset($_GET['id_evento'])) {
|
||||
$colname_atualiza_imagem = $_GET['id_evento'];
|
||||
}
|
||||
mysql_select_db($database_conn_sustentabilidade, $conn_sustentabilidade);
|
||||
$query_atualiza_imagem = sprintf("SELECT * FROM tbeventos WHERE id_evento = %s", GetSQLValueString($colname_atualiza_imagem, "int"));
|
||||
$atualiza_imagem = mysql_query($query_atualiza_imagem, $conn_sustentabilidade) or die(mysql_error());
|
||||
$row_atualiza_imagem = mysql_fetch_assoc($atualiza_imagem);
|
||||
$totalRows_atualiza_imagem = mysql_num_rows($atualiza_imagem);
|
||||
|
||||
if(isset($_POST['enviar'])){
|
||||
$nome_img=$_FILES['imagem_evento']['name'];
|
||||
$tmp_img=$_FILES['imagem_evento']['tmp_name'];
|
||||
$dir_img="../imagens/".$nome_img;
|
||||
move_uploaded_file($tmp_img,$dir_img);
|
||||
}
|
||||
|
||||
?>
|
||||
<!doctype html>
|
||||
<html lang="pt-br">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Evento - Altera Imagem</title>
|
||||
<link href="../bootstrap/css/bootstrap.min.css" rel="stylesheet">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<nav>
|
||||
<?php include("menu_adm.php"); ?>
|
||||
</nav>
|
||||
<section>
|
||||
<h4> <a href="index.php">Voltar</a></h4>
|
||||
<h1>Alterar Imagem</h1>
|
||||
<article>
|
||||
<img src="../imagens/<?php echo $row_atualiza_imagem['imagem_evento']; ?>" alt="" width="300px">
|
||||
|
||||
<form action="<?php echo $editFormAction; ?>" enctype="multipart/form-data" method="POST" name="form_evento_imagem">
|
||||
<input type="hidden" name="id_evento" id="id_evento" value="<?php echo $row_atualiza_imagem['id_evento']; ?>">
|
||||
|
||||
<p>
|
||||
Escolha o arquivo:
|
||||
<input type="file" name="imagem_evento" id="imagem_evento" required>
|
||||
</p>
|
||||
<p>
|
||||
<input type="submit" value="Atualizar" name="enviar" id="enviar">
|
||||
</p>
|
||||
<input type="hidden" name="MM_update" value="form_evento_atualiza">
|
||||
|
||||
|
||||
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
</article>
|
||||
|
||||
|
||||
|
||||
</section>
|
||||
<!-- Jquery (obrigatório para plugin JS do Bootstrap) -->
|
||||
<script src="../bootstrap/jquery.min.js"></script>
|
||||
<!-- Plugin JS-->
|
||||
<script src="../bootstrap/js/bootstrap.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
mysql_free_result($atualiza_imagem);
|
||||
?>
|
Reference in New Issue
Block a user