How to show an alert box in PHP?

prakash_d22 picture prakash_d22 · Dec 12, 2012 · Viewed 661.7k times · Source

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.

Answer

Yogesh Suthar picture Yogesh Suthar · Dec 12, 2012

use this code

echo '<script language="javascript">';
echo 'alert("message successfully sent")';
echo '</script>';

The problem was:

  1. you missed "
  2. It should be alert not alery