How to write code for a PHP alert box?

To display a message box in PHP, you can achieve this by using the alert function in JavaScript. Here is a simple example code:

<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    // 处理表单提交
    // ...

    // 弹出提示框
    echo '<script>alert("提交成功!");</script>';
}
?>

<!DOCTYPE html>
<html>
<head>
    <title>弹出提示框</title>
</head>
<body>
    <form method="POST">
        <!-- 表单内容 -->
        <input type="submit" value="提交">
    </form>
</body>
</html>

In the example above, PHP code is executed to handle form submission when the user clicks the submit button, and then JavaScript code is echoed to display a popup message. The message in the popup can be modified as needed.

Leave a Reply 0

Your email address will not be published. Required fields are marked *


广告
Closing in 10 seconds
bannerAds