How do you display a JavaScript alert from PHP?
javascript, php
Solution
instead of:
echo "Data has been submitted to $to!";
just
echo '<script type="text/javascript">alert("Data has been submitted to ' . $to . '");</script>';
Problem
I don't code in PHP, but I have this form which I pulled off the web and its working great: What I would like to do is somehow add some code in here that can fire up a JS script, simple alert box, saying "Thank you form is submitted". After the form was received by this mailer.php file. ``` <?php if(isset($_POST['submit'])) { $to = "myEmail@email.com"; $subject = "Form Tutorial"; $name_field = $_POST['name']; $email_field = $_POST['email']; $message = $_POST['message']; $body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message"; echo "Data has been submitted to $to!"; mail($to, $subject, $body); } else { echo "blarg!"; } ?> ```