How to put a warning window using PHP?

How to put a warning window using PHP?

+103
javascript php popup messagebox
Dec 13 '12 at 1:27
source share
8 answers

You can 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>"; 
+227
Dec 13
source share

Create alert function

 <?php alert("Hello World"); function alert($msg) { echo "<script type='text/javascript'>alert('$msg');</script>"; } ?> 
+12
Nov 29 '16 at
source share

I did it as follows:

 <?php $PHPtext = "Your PHP alert!"; ?> var JavaScriptAlert = <?php echo json_encode($PHPtext); ?>; alert(JavaScriptAlert); // Your PHP alert! 
+3
Jun 24 '14 at 23:05
source share

PHP provides HTML and Javascript to be sent to the client browser. PHP is a server language. This allows him to do something like INSERT in a database on the server.

But the warning is displayed by the client browser. You will need to work through javascript to get a warning.

+2
Dec 13
source share

Use jquery between php $ command Warning

0
Dec 13
source share

See this example:

 <?php echo "<div id='div1'>text</div>" ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <title></title> <script src="js/jquery1.3.2/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function () { $('#div1').click(function () { alert('I clicked'); }); }); </script> </head> <body> </body> </html> 
0
Aug 24 '15 at 7:50
source share

This .php file will generate valid HTML with a warning (you can even remove <?php...?> )

 <!DOCTYPE html><html><title>p</title><body onload="alert('<?php echo 'Hi' ?>')"> 
0
Apr 12 '19 at 13:51
source share

You can use DHP for this. It is absolutely simple and fast than a script. Just write alert('something'); This is not a programming language, it is something like jquery highlighting. You need dhp.php at the top and bottom to need dhpjs.php. It is not open source yet, but when you can use it. This is our programming language;)

-3
Mar 26 '16 at 10:36
source share



All Articles