How to show an alert box in PHP?
715,315
Solution 1
use this code
echo '<script language="javascript">';
echo 'alert("message successfully sent")';
echo '</script>';
The problem was:
- you missed
"
- It should be
alert
notalery
Solution 2
Try this:
Define a funciton:
<?php
function phpAlert($msg) {
echo '<script type="text/javascript">alert("' . $msg . '")</script>';
}
?>
Call it like this:
<?php phpAlert( "Hello world!\\n\\nPHP has got an Alert Box" ); ?>
Solution 3
There is a syntax error (typo):
It's alert
not alery
.
Solution 4
echo "<script>alert('same message');</script>";
This may help.
Solution 5
echo '<script language="javascript>';
Seems like a simple typo. You're missing a double-quote.
echo '<script language="javascript">';
This should do.
Comments
-
prakash_d22 almost 2 years
I want to display an alert box showing a message with PHP.
Here is my PHP code:
<?php header("Location:form.php"); echo '<script language="javascript">'; echo 'alert(message successfully sent)'; //not showing an alert box. echo '</script>'; exit; ?>
But it is not working.