JavaScript: Displaying Message after a Action, say Form Submit

You need to display a message after any action to confirm about successful completion of the action or for some error.

Suppose user has submitted a web form and you got everything fine. So in PHP you have this script:

if (count($_POST))
// checking / validation etc
// Db insert etc
## Now display message to users about successful form submit
echo '<script> alert("Form submitted successfully/ Email sent etc.") </script>';
## 2. message
if (! count($_POST))
<form method="post" action="">

In the above method, Visitor will get javascript alert box having your message.
Many does not like javascript alert box jumped to them. User need to click on them.

Instead of using above method, have a message displayed using PHP itself on web page.
Replace <code>echo '<script> alert("Form submitted successfully/ Email sent etc.") </script>';</code>
with <code> $msg = 'Form submitted successfully/ Email sent etc';</code>
and write this line
echo @$msg;
below the line ## 2. message.
You can add some color/ design to your message here:
$msg = '<p><b style="color:blue">Form submitted successfully/ Email sent etc</b></p>';

Comments are open for an year period. Please, write here on Facebook page.