first_php_project/admin/tipo_altera.php
2021-11-19 22:12:23 -03:00

126 lines
4.9 KiB
PHP
Executable File

<?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_tipo_insere")) {
$updateSQL = sprintf("UPDATE tbtipos SET sigla_tipo=%s, rotulo_tipo=%s WHERE id_tipo=%s",
GetSQLValueString($_POST['sigla_tipo'], "text"),
GetSQLValueString($_POST['rotulo_tipo'], "text"),
GetSQLValueString($_POST['id_tipo'], "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_tipos = "-1";
if (isset($_GET['id_tipo'])) {
$colname_atualiza_tipos = $_GET['id_tipo'];
}
mysql_select_db($database_conn_sustentabilidade, $conn_sustentabilidade);
$query_atualiza_tipos = sprintf("SELECT * FROM tbtipos WHERE id_tipo = %s", GetSQLValueString($colname_atualiza_tipos, "int"));
$atualiza_tipos = mysql_query($query_atualiza_tipos, $conn_sustentabilidade) or die(mysql_error());
$row_atualiza_tipos = mysql_fetch_assoc($atualiza_tipos);
$totalRows_atualiza_tipos = mysql_num_rows($atualiza_tipos);
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Tipos - Insere</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 id="topo" class="container-fluid">
<section id="titulo" class="container">
<h1>Tipos - Altera</h1>
<hr>
</section>
</section>
<section id="insere_centro" class="container-fluid">
<section id="form" class="container">
<form name="form_tipo_insere" action="<?php echo $editFormAction; ?>" method="POST" id="form_rotulo_insere" enctype="multipart/form-data">
<input type="hidden" name="id_tipo" id="id_tipo" value="<?php echo $row_atualiza_tipos['id_tipo'];?>">
<label for="rotulo_tipo">Rótulo:</label>
<p class="input-group">
<span class="input-group-addon"></span>
<input name="rotulo_tipo" class="form-control input" type="text" id="rotulo_tipo" maxlength="15" value="<?php echo $row_atualiza_tipos['rotulo_tipo']?>" required placeholder="Digite o rótulo">
</p>
<label for="sigla_tipo">Sigla:</label>
<p class="input-group">
<span class="input-group-addon"></span>
<input name="sigla_tipo" class="form-control input" type="text" id="sigla_tipo" maxlength="3" value="<?php echo $row_atualiza_tipos['sigla_tipo']?>"required placeholder="Digite uma sigla" >
</p>
<p><div class="btn-group btn-group-justified" role="group" aria-label="...">
<div class="btn-group" role="group">
<input class="btn btn-success btn-block" type="submit" value="Atualizar">
</div>
<div class="btn-group" role="group">
<input class="btn btn-danger btn-block" type="reset" value="Limpar">
</div>
</div>
<input type="hidden" name="MM_update" value="form_tipo_insere">
</p>
</form>
</section>
</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_tipos);
?>