Last active
May 25, 2022 12:03
-
-
Save dantetesta/bf575a62e05dcb5f8f57c74617f5329b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*BY: ASK JARVIS + DANTE TESTA */ | |
<?php | |
$cep = $_POST['cep']; | |
$conexao = mysqli_connect('localhost', 'user', 'senha', 'ceps'); | |
$query = "SELECT * FROM ceps WHERE cep = '$cep'"; | |
$result = mysqli_query($conexao, $query); | |
if(mysqli_num_rows($result) > 0){ | |
echo 'true'; | |
}else{ | |
echo 'false'; | |
} | |
?> | |
<input type="text" id="cep" size="20"> | |
<input type="button" id="validar" value="Consultar CEP"> | |
<script> | |
jQuery('#validar').click(function(){ | |
var cep = jQuery('#cep').val().replace(/\D/g, ''); | |
if(cep.length == 8){ | |
jQuery.ajax({ | |
url: 'https://velozen.com.br/pesquisa-cep.php', | |
type: 'POST', | |
data: {cep: cep}, | |
success: function(data){ | |
if(data == 'true'){ | |
jQuery('.sim').css('display','block'); | |
jQuery('.nao, .info').css('display','none'); | |
}else{ | |
jQuery('.nao').css('display','block'); | |
jQuery('.sim, .info').css('display','none'); | |
} | |
} | |
}); | |
}else{ | |
jQuery('.info').css('display','block'); | |
jQuery('.nao, .sim').css('display','none'); | |
} | |
}); | |
</script> | |
<style> | |
.sim, .nao, .info { | |
display: none; | |
} | |
#cep { | |
font-size: 22px; | |
border: 1px solid #999999; | |
padding: 10px; | |
font-weight: bold; | |
color: #333333; | |
} | |
#validar { | |
font-size: 17px; | |
border: 0px solid black; | |
padding: 10px; | |
background: #61CE70; | |
color: white; | |
margin: 15px 0 0 0; | |
} | |
#validar:hover { | |
background: black; | |
color: white; | |
} | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment