php popup message code example

Example 1: alert in php

echo '<script>alert("Message")</script>';

Example 2: php pop up message

Copy Code<?php
function  createConfirmationmbox(){
    echo '<script type="text/javascript"> ';
    echo 'var inputname = prompt("Please enter your name", "");';
    echo 'alert(inputname);';
    echo '</script>';
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>JavaScript Prompt Box by PHP</title>
<?php
    createConfirmationmbox();
?>
</head>
<body>
</body>
</html>

Example 3: php pop up message

Copy Code<?php
function  createConfirmationmbox(){
    echo '<script type="text/javascript"> ';
    echo ' function openulr(newurl) {';
    echo '  if (confirm("Are you sure you want to open new URL")) {';
    echo '    document.location = newurl;';
    echo '  }';
    echo '}';
    echo '</script>';
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>JavaScript Alert Box by PHP</title>
<?php
createConfirmationmbox();
?>
</head>
<body>
<strong><a href="javascript:openulr('newurl.html');">Open new URL</a></strong>
</body>
</html>

Example 4: php pop up message

Copy Code<script Type="javascript">alert("JavaScript Alert Box by PHP")</script>

Example 5: php pop up message

Copy Code<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>JavaScript Alert Box by PHP</title>
<script type="text/javascript">  function openulr(newurl) {  if (confirm("Are you sure you want to open new URL")) {    document.location = newurl;  }}</script></head>
<body>
<strong><a href="javascript:openulr('newurl.html');">Open new URL</a></strong>
</body>
</html>

Example 6: php pop up message

Copy Code<script type="text/javascript"> var inputname = prompt("Please enter your name", "");alert(inputname);</script></head>

Tags:

Php Example