What you want to do is something relatively simple, but it is necessary to know how you are doing this task, if you have some scheme like mvc or if you are doing it in a procedural way, if you are doing it in the same file or if you are directing the action to another file.
But I will try to assume that you are using a procedural method and that you are performing the task in the same file.
First of all I recommend to work your Alerts as bootstrap and when you are more experienced use Alertsweet and leave this information displayed more professionally and stylized.
Okay, let’s go to the code.
Use only the statement in a javascript scope and you can do the whole task as follows.
echo "<script> alert('".$nome."! Sua mensagem foi enviada com sucesso!');
window.reload(); </script>"
If you want to be directed to another page using javascript after Alert display, replace window.reload()
for window.location.href
, Exp: redirect to google page window.location.href= "https://google.com";
, if you do not use the http or https indexing identifier, the code will interpret that the string is part of your project and will try to search for it as a suffix or file, this may be useful if you are validating your email sending in another file.
I recommend that you see to start your studies the Phpmailer for sending emails, the sending of native php is very inefficient in production environment has no investment of people committed to its improvement long.
I hope I helped. Hugs!
gives a tidy in the Code!
– Edu Mendonça
Thanks, Aderbal. Yes I organized the code, I found myself and I got it solved! Abs
– ÉdiQuadros