0
I’m studying a little bit about web programming, and trying to create a virtual store to train, but some things are still not very clear to me. I am trying to assemble the part of user registration/ login and I read that the PDO method is safer against intrusions of type sql Injection than using the post method, until I started to do by Pdo, but I’m having trouble presenting messages to the user due to the refresh that the page gives after the action of registering for example. Then recently I saw a tutorial on youtube that taught in the form below. Can anyone tell me if this form is safe or if this code is passive to be invaded?
<!--AJAX PARA INSERÇÃO DOS DADOS -->
<script type="text/javascript">
$(document).ready(function(){
$('#btn-cadastro').click(function(event){
event.preventDefault();
$.ajax({
url: "cadastrar-usuario.php",
method: "post",
data: $('form').serialize(),
dataType: "text",
success: function(mensagem){
$('#mensagem').removeClass()
if(mensagem == 'Cadastrado com Sucesso!!'){
$('#mensagem').addClass('text-success')
document.getElementById('username').value = document.getElementById('email').value;
document.getElementById('pass').value = document.getElementById('senha').value;
$('#nome').val('')
$('#telefone').val('')
$('#cpf').val('')
$('#email').val('')
$('#senha').val('')
//$('#btn-fechar').click();
//location.reload();
}else{
$('#mensagem').addClass('text-danger')
}
$('#mensagem').text(mensagem)
},
})
})
})
</script>
<!--AJAX PARA RECUPERAR A SENHA -->
<script type="text/javascript">
$(document).ready(function(){
$('#btn-rec').click(function(event){
event.preventDefault();
$.ajax({
url: "recuperar.php",
method: "post",
data: $('form').serialize(),
dataType: "text",
success: function(mensagem){
$('#mensagem2').removeClass()
if(mensagem == 'Senha enviada para o seu Email!'){
$('#mensagem2').addClass('text-success')
document.getElementById('username').value = document.getElementById('email-recuperar').value;
$('#email-recuperar').val('')
//$('#btn-fechar').click();
//location.reload();
}else{
$('#mensagem2').addClass('text-danger')
}
$('#mensagem2').text(mensagem)
},
})
})
})
</script> ```
Do not confuse PDO with the POST request method.
– Marcos Xavier