0
I’m creating a message using the resource Sweet Alert, and where I need to present the person’s name inside a Alert coming from a variable PHP.So, I wonder how I can do it properly.
Note: . The connection to the database is working perfectly.
echo "<script>
swal({
title: 'Usuário Cadastrado.',
text: 'Gostaria de cadastrar os documentos do usuário **<?php echo $usuario ['nome']?>**?',
type: 'success',
cancelButtonText: 'Cancelar',
showCancelButton: true,
confirmButtonColor: '#00c292',
confirmButtonText: 'Sim, Cadastrar',
closeOnConfirm: true
}, function(){
window.location.href = 'novo_usuario';
});
</script>";
}
?>
Notice that on the line I informed the PHP code
text: 'Gostaria de cadastrar os documentos do usuário **<?php echo $usuario ['nome']?>**?',
Possible duplicate of I can make Javascript write PHP?
– Amadeu Antunes