If you want to display the PHP $msg
message, you can do two simple ways:
Short:
<div class="mensagem"><?= $msg ?></div>
Traditional:
<div class="mensagem"><?php echo $msg; ?></div>
You can also do this using JavaScript / JQuery, but I do not see why you would do this in this example:
<div class="mensagem"></div>
JavaScript:
<script>
document.querySelector('.mensagem').innerText = '<?= $msg ?>';
</script>
JQuery:
<script>
$('.mensagem').text('<?= $msg ?>');
</script>
You could see:
Video courses that can get you started:
There are other courses besides those on his channel, this channel is great for those starting out.