BossBey File Manager
PHP:
8.4.18
OS:
Linux
User:
kids
Root
/
home
/
kids
/
public_html
/
app
📤 Upload
📝 New File
📁 New Folder
Close
Editing: create.php
<!DOCTYPE html> <html lang="pt-br"> <head> <meta charset="UTF-8"> <title>Criação de usuário no sistema</title> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"> <style> .wrapper{ width: 500px; margin: 0 auto; } </style> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> </head> <body> <div class="wrapper"> <div class="container-fluid"> <div class="row"> <div class="col-md-12"> <h2 class="mt-5">Criar usuário</h2> <form action="insert.php" method="post"> <div class="form-group"> <label>Nome</label> <input type="text" name="nome" class="form-control"> </div> <div class="form-group"> <label>Data de Nascimento (dd/mm/aaaa)</label> <input type="text" name="nascimento" class="form-control" placeholder="dd/mm/aaaa" pattern="\d{2}/\d{2}/\d{4}" required> <small class="form-text text-muted">Formato: dd/mm/aaaa</small> </div> <div class="form-group"> <label>Email</label> <input type="email" name="email" class="form-control"> </div> <div class="form-group"> <label>Telefone</label> <input type="text" name="telefone" class="form-control"> </div> <div class="form-group"> <label>Nível de Acesso</label> <select name="nivelAcesso" class="form-control"> <option value="admin">Admin</option> <option value="prof">Prof</option> <option value="resp">Resp</option> <option value="aluno">Aluno</option> </select> </div> <div class="form-group"> <label for="cep">CEP:</label> <input type="text" id="cep" name="cep" maxlength="9" onblur="pesquisarEndereco(this.value)" required> </div> <div class="form-group"> <label for="logradouro">Logradouro:</label> <input type="text" id="logradouro" name="logradouro" required> </div> <div class="form-group"> <label for="bairro">Bairro:</label> <input type="text" id="bairro" name="bairro" required> </div> <div class="form-group"> <label for="cidade">Cidade:</label> <input type="text" id="cidade" name="cidade" required> </div> <div class="form-group"> <label for="estado">Estado:</label> <input type="text" id="estado" name="estado" required> </div> <div class="form-group"> <label for="numero">Número:</label> <input type="text" id="numero" name="numero" required> </div> <div class="form-group"> <label for="complemento">Complemento:</label> <input type="text" id="complemento" name="complemento"> </div> <div class="form-group"> <label for="latitude">Latitude:</label> <input type="text" id="latitude" name="latitude" required> </div> <div class="form-group"> <label for="longitude">Longitude:</label> <input type="text" id="longitude" name="longitude" required> </div> <div class="form-group"> <label>Observações</label> <textarea name="obs" class="form-control" rows="5"></textarea> </div> <input type="submit" class="btn btn-primary" value="Submit"> </form> </div> </div> </div> </div> <script> function pesquisarEndereco(cep) { cep = cep.replace(/\D/g, ''); if (cep.length === 8) { fetch(`https://viacep.com.br/ws/${cep}/json/`) .then(response => response.json()) .then(data => preencherEndereco(data)); } } function preencherEndereco(data) { document.getElementById('logradouro').value = data.logradouro || ''; document.getElementById('bairro').value = data.bairro || ''; document.getElementById('cidade').value = data.localidade || ''; document.getElementById('estado').value = data.uf || ''; document.getElementById('complemento').value = data.complemento || ''; } function obterLatitudeLongitude() { const logradouro = document.getElementById('logradouro').value; const numero = document.getElementById('numero').value; const complemento = document.getElementById('complemento').value; const bairro = document.getElementById('bairro').value; const cidade = document.getElementById('cidade').value; const estado = document.getElementById('estado').value; if (logradouro && numero && bairro && cidade && estado) { const enderecoCompleto = `${logradouro}, ${numero} ${complemento}, ${bairro}, ${cidade}, ${estado}`; const apiKey = 'AIzaSyAki4atbA8ey0lMY4ByHeF8qaGWvQ8HlGM'; // Substitua pela sua própria API Key const url = `https://maps.googleapis.com/maps/api/geocode/json?address=${encodeURIComponent(enderecoCompleto)}&key=${apiKey}`; $.get(url, function (data) { if (data.results && data.results.length > 0) { const latitude = data.results[0].geometry.location.lat; const longitude = data.results[0].geometry.location.lng; document.getElementById('latitude').value = latitude; document.getElementById('longitude').value = longitude; } else { alert('Endereço não encontrado.'); } }); } } document.getElementById('cep').addEventListener('blur', function() { const cep = document.getElementById('cep').value; if (cep) { pesquisarEndereco(cep); } }); const enderecoFields = ['logradouro', 'numero', 'complemento', 'bairro', 'cidade', 'estado']; enderecoFields.forEach(field => { document.getElementById(field).addEventListener('blur', obterLatitudeLongitude); }); document.addEventListener('DOMContentLoaded', function () { const inputNascimento = document.querySelector('input[name="nascimento"]'); inputNascimento.addEventListener('input', function () { const inputValue = inputNascimento.value; // Verificar se o comprimento é 2 ou 5 if (inputValue.length === 2 || inputValue.length === 5) { // Adicionar uma barra ("/") se o comprimento for 2 ou 5 inputNascimento.value += '/'; } }); }); </script> </body> </html>
Save
Cancel