using js alert inside php code code example
Example 1: alert in php
echo '<script>alert("Message")</script>';
Example 2: php echo alert js
echo '<script type="text/javascript">alert("Data has been submitted to ' . $to . '");</script>';
echo '<script>alert("Message")</script>';
echo '<script type="text/javascript">alert("Data has been submitted to ' . $to . '");</script>';