146 lines
		
	
	
		
			5.6 KiB
		
	
	
	
		
			PHP
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			146 lines
		
	
	
		
			5.6 KiB
		
	
	
	
		
			PHP
		
	
	
		
			Executable File
		
	
	
	
	
<!-- Alterações do código -->
 | 
						|
<!-- 28/11/2018 -->
 | 
						|
<!-- Consertei erros gramaticais -->
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<?php require_once('../Connections/conn_sustentabilidade.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_insert"])) && ($_POST["MM_insert"] == "form-usuarios-insere")) {
 | 
						|
  $insertSQL = sprintf("INSERT INTO tbusuarios (id_usuario, login_usuario, senha_usuario, nivel_usuario) VALUES (%s, %s, %s, %s)",
 | 
						|
                       GetSQLValueString($_POST['id_usuario'], "int"),
 | 
						|
                       GetSQLValueString($_POST['login_usuario'], "text"),
 | 
						|
                       GetSQLValueString($_POST['senha_usuario'], "text"),
 | 
						|
                       GetSQLValueString($_POST['nivel_usuario'], "text"));
 | 
						|
 | 
						|
  mysql_select_db($database_conn_sustentabilidade, $conn_sustentabilidade);
 | 
						|
  $Result1 = mysql_query($insertSQL, $conn_sustentabilidade) or die(mysql_error());
 | 
						|
 | 
						|
  $insertGoTo = "usuarios_lista.php";
 | 
						|
  if (isset($_SERVER['QUERY_STRING'])) {
 | 
						|
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
 | 
						|
    $insertGoTo .= $_SERVER['QUERY_STRING'];
 | 
						|
  }
 | 
						|
  header(sprintf("Location: %s", $insertGoTo));
 | 
						|
}
 | 
						|
?>
 | 
						|
<!doctype html>
 | 
						|
<html>
 | 
						|
<head>
 | 
						|
<meta charset="utf-8">
 | 
						|
<title>Usuarios Insere</title>
 | 
						|
 | 
						|
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
 | 
						|
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
 | 
						|
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
 | 
						|
<!------ Include the above in your HEAD tag ---------->
 | 
						|
 | 
						|
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
 | 
						|
<script src="http://getbootstrap.com/dist/js/bootstrap.min.js"></script>
 | 
						|
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
 | 
						|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
 | 
						|
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.10/css/all.css" integrity="sha384-+d0P83n9kaQMCwj8F4RJB66tzIwOKmrdb46+porD/OvrJ+37WqIM7UoBtwHO6Nlg" crossorigin="anonymous">
 | 
						|
	
 | 
						|
	
 | 
						|
</head>
 | 
						|
 | 
						|
<body>
 | 
						|
	<section class="container-fluid">
 | 
						|
		
 | 
						|
        		<section class="container">
 | 
						|
					
 | 
						|
					<section class="col-xs-12 col-sm-offset col-sm-8 col-md-offset col-md-6 col-lg-offset-4 col-lg-4">
 | 
						|
						
 | 
						|
				<h4><a href="usuarios_lista.php">Voltar</a></h4>
 | 
						|
				<h1>Usuários-Insere</h1>
 | 
						|
				<hr>
 | 
						|
<form name="form-usuarios-insere" action="<?php echo $editFormAction; ?>" method="POST" id="form_usuarios_insere" enctype="multipart/form-data">
 | 
						|
				<input type="hidden" name="id_usuario">
 | 
						|
		
 | 
						|
				
 | 
						|
					
 | 
						|
					
 | 
						|
						
 | 
						|
                <label for="nome_usuario">Nome:</label>
 | 
						|
                <p class="input-group">
 | 
						|
                    <span class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span>
 | 
						|
                    <input name="login_usuario" class="form-control input" type="text" id="login_usuario" maxlength="30" required placeholder="Digite o seu login">
 | 
						|
                </p>
 | 
						|
				  
 | 
						|
				<label for="senha_usuario">Senha:</label>
 | 
						|
                <p class="input-group">
 | 
						|
                    <span class="input-group-addon">
 | 
						|
						<i class="fas fa-lock"></i></span>
 | 
						|
                    <input name="senha_usuario" class="form-control input" type="password" id="senha_usuario" maxlength="16" required placeholder="Digite sua senha">
 | 
						|
                </p>
 | 
						|
					
 | 
						|
               
 | 
						|
	
 | 
						|
                <br>
 | 
						|
 | 
						|
                			
 | 
						|
				<h5>Nivel de Usúario:<h5>
 | 
						|
			    <p class="hidden"><b>Nível de Permissão:</b><br>
 | 
						|
                <p>
 | 
						|
					<input name="nivel_usuario" type="radio" id="nivel_usuario" value="sup" required>
 | 
						|
                    <label for="nivel_usuario_sup">Super Usuário</label>
 | 
						|
                    
 | 
						|
					<br>
 | 
						|
					
 | 
						|
					<input name="nivel_usuario" type="radio" id="nivel_usuario" value="com" required checked>
 | 
						|
                    <label for="nivel_usuario_com"> <b>Usuário Comum</b></label>
 | 
						|
                    </p>
 | 
						|
                
 | 
						|
					<p><input class="btn btn-success " type="submit" value="Registrar">
 | 
						|
						
 | 
						|
					    
 | 
						|
					
 | 
						|
	                <input class="btn btn-danger " type="submit" value="Limpar"></p>
 | 
						|
					
 | 
						|
	                <input type="hidden" name="MM_insert" value="form-usuarios-insere">
 | 
						|
					
 | 
						|
					
 | 
						|
					
 | 
						|
					</section>
 | 
						|
                      </section>
 | 
						|
						</section>
 | 
						|
            </form>
 | 
						|
		
 | 
						|
</body>
 | 
						|
</html>
 |