p>
<?php
echo "<script>alert('bem vindo ao site');</script>";
?>
It is not very recommended to send a message through the alert, this is the user can disable the alert, so it can happen that he does not receive his message the second time, a way to get around this would be a hidden part of the page with the message , example a div
<div id="kodomsg" style="display: none">
senha invalida
</div>
When you need to display that message simply simply display it, you can use JS to do it dynamically
<script>
var minhamsg = document.getElementById("kodomsg");
minhamsg.style.display = "block"; //"none" para ocultar
</script>
You can create a function to show / hide and call it for a specific event, example as soon as you press a button
<div id="kodomsg" style="display: none">
era uma vez um botão ... fim da historia
</div>
<input type="button" value="aperte" onclick="kodofun()">
<script>
function kodofun(){
var minhamsg = document.getElementById("kodomsg");
minhamsg.style.display = "block"; //"none" para ocultar
}
</script>
It does not necessarily have to be static You can change the message itself dynamically by JS too
<div id="kodomsg" style="display: none">
senha invalida
</div>
<script>
var minhamsg = document.getElementById("kodomsg");
minhamsg.innerHTML = "essa é a nova msg";
</script>
You can even create something like alert, let the div float by overlapping the page with a button to close it using js and css, you can even customize it the way you like
<style>
#kodomsg{
background-color: blue;
width: 200px;
height: 60px;
position: absolute;
left: 20%;
top: 20%;
}
</style>
<div id="kodomsg">
bem vindo ao site<br>
<input type="button" value="fechar" onclick="kodofechar()">
</div>
<script>
function kodofechar(){
var minhamsg = document.getElementById("kodomsg");
minhamsg.style.display = "none";
}
</script>
There are many interesting ways to do this as there are many applications for this ^^ (ps: my example is ugly for damn kkk)