alert message in php – Displaying An Alert Message Box

Rate this post

alert message in php – Alert boxes are used for displaying a warning message to the user. php script alert message Code Example.

alert message in php – pop an alert message box

The alert message just like a pop-up window on the screen using PHP and JavaScript. There are three types of pop-up boxes Like as a Alert box, Confirm box and Prompt box.

In this example, I will learn you how to display alert message in php.

you can easy and simply display alert message in php.

Example

<?php

echo '<script>alert("Welcome to Pakainfo.com")</script>';
?>

PHP program to pop up an alert box on the screen
Example : 2

<?php

function getWebInfo($website_notify) {
      
    echo "<script>alert('$website_notify');</script>";
}
  
getWebInfo("Welcome to Pakainfo.com");
  
?>

Don’t Miss : Sweet alert php MySQL

Free Live Chat for Any Issue

How to Display Alert Message Box in PHP?

Example : 1. Display alert box in PHP

<html>
<head>
<meta charset="utf-8">
<title>JavaScript Alert Box by PHP - www.pakainfo.com</title>
<?php  
echo '<script type="text/javascript">';
echo ' alert("Welcome To Pakainfo.com")';
echo '</script>';
?>
</head>

<body>
</body>
</html>

Example : 2 Using the PHP function

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

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

Example : 3 Display confirm box in PHP
Example: Using the Javascript confirmation pop-up box

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

Example : 4 Display prompt box in PHP

<html>
<head>
<meta charset="utf-8">
<title>JavaScript Prompt Box by PHP - www.pakainfo.com</title>
<?php
function  genrateWebInfo(){
    echo '<script type="text/javascript"> ';
    echo 'var websitename = prompt("Please enter your Website Name", "");';
    echo 'alert(websitename);';
    echo '</script>';
}
?>
<?php
    genrateWebInfo();
?>
</head>
<body>
</body>
</html>

php script alert message

alert in php

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

allert in php

$message = "Welcome To Pakainfo.com";
echo "<script type='text/javascript'>alert('$message');</script>";

Download

I hope you get an idea about alert message in php.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.