pop alert inside php page code example

Example 1: 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 2: php pop up message

Copy Code<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>JavaScript Alert Box by PHP</title>
<?php
function_alert("We welcome the New World");

function function_alert($msg) {
    echo "<script type='text/javascript'>alert('$msg');</script>";
}
?>
</head>
<body>
</body>
</html>

Tags:

Php Example