You could use Javascript:

// This is in the PHP file and sends a Javascript alert to the client
$message = "wrong answer";
echo "<script type='text/javascript'>alert('$message');</script>";
Answer from Peter Gluck on Stack Overflow
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ php โ€บ how-to-pop-an-alert-message-box-using-php
How to Pop an Alert Message Box using PHP? - GeeksforGeeks
July 12, 2025 - <?php // PHP program to pop an alert // message box on the screen // Function definition function function_alert($message) { // Display the alert box echo "<script>alert('$message');</script>"; } // Function call function_alert("Welcome to Geeks for Geeks"); ?>
๐ŸŒ
W3Schools
w3schools.com โ€บ howto โ€บ howto_js_alert.asp
How To Create an Alert Message Box
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP, Bootstrap, Java, XML and more.
๐ŸŒ
STechies
stechies.com โ€บ display-alert-message-box-dialogue-box-using-php
How to Display Alert Message Box in PHP?
<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>
๐ŸŒ
Simplilearn
simplilearn.com โ€บ home โ€บ resources โ€บ software development โ€บ alert in php: displaying an alert message box in php
Alert in PHP: Displaying An Alert Message Box in PHP
January 26, 2025 - Deep dive into alert in PHP tutorial and learn how to display an โš ๏ธ alert message box in PHP, types of pop-up boxes with examples. Start learning now!
Address ย  5851 Legacy Circle, 6th Floor, Plano, TX 75024 United States
๐ŸŒ
W3Schools
w3schools.com โ€บ jsref โ€บ met_win_alert.asp
Window alert() Method
The alert() method displays an alert box with a message and an OK button. The alert() method is used when you want information to come through to the user.
๐ŸŒ
Scaler
scaler.com โ€บ home โ€บ topics โ€บ php alert
PHP alert - Scaler Topics
April 1, 2024 - Want to create custom alerts in your PHP code? Our guide will teach you how to create personalized alert messages to enhance user experience on Scaler topics.
๐ŸŒ
SitePoint
sitepoint.com โ€บ php
How to crate a dialog box in php - PHP - SitePoint Forums | Web Development & Design Community
August 29, 2011 - <?php if(isset($_POST['email'])) { //Email $email_to = "email@email.com"; $email_subject = "CG Contact Form Submission"; function died($error) { // error message code echo "We are very sorry, but there were error(s) found with the form your submitted.
Find elsewhere
๐ŸŒ
WebDeveloper.com
webdeveloper.com โ€บ community โ€บ 51443-message-box-in-php
Message Box In PHP
Copy linkTweet thisAlerts: @scragarDec 14.2004 โ€” #you want an if in there to prevent it running the SQL and displaying your input message if it's refreshed. [code=php] <? session_start(); // this MUST go at the TOP of the page. $NoRepeatsFor = 1000 * 60; // this is 1 minute.
๐ŸŒ
W3Schools
w3schools.com โ€บ php โ€บ php_form_complete.asp
PHP Complete Form Example
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP, Bootstrap, Java, XML and more.
๐ŸŒ
W3Schools
w3schools.com โ€บ jsref โ€บ met_win_confirm.asp
Window confirm() Method
The confirm() method displays a dialog box with a message, an OK button, and a Cancel button.
๐ŸŒ
W3Schools
w3schools.com โ€บ bootstrap โ€บ bootstrap_alerts.asp
Bootstrap Alerts
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP, Bootstrap, Java, XML and more.
๐ŸŒ
PHP-Fusion
guttitech.com โ€บ phpfusion โ€บ articles.php
PHP-Fusion Powered Website - Articles: JavaScript Message Box
In the first example we are going to create simple Alert Box on button click , so when user click on button he or she able to see pop up message window and once done, by clicking on Ok button popup window get closed.
๐ŸŒ
PHP
php.net โ€บ manual โ€บ en โ€บ ui-window.msg.php
PHP: UI\Window::msg - Manual
UI\Window::msg โ€” Show Message Box ยท public UI\Window::msg(string $title, string $msg) Shall show a message box ยท title ยท The title of the message box ยท msg ยท The message ยท Learn How To Improve This Page โ€ข Submit a Pull Request โ€ข ...
๐ŸŒ
Wordpress
bdhacker.wordpress.com โ€บ my_alert
PHP Alert Box โ€“ Anything but "Hacking"
December 1, 2010 - Welcome to my_alert: A PHP-JS based Alert System! An aleternative of JavaScript's Ugly alert() function! ;) It Uses JS actually to make alert-boxes & PHP for the easiest-maintanence of codes. Screenshot Live Demo: Go to this link, checkout the effects and message-box.
๐ŸŒ
W3Schools
w3schools.com โ€บ howto โ€บ howto_css_modals.asp
W3Schools.com
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP, Bootstrap, Java, XML and more.