首页 > 解决方案 > 表单、PHP(自制)函数和刷新页面的怪异行为

问题描述

我的 PHP 脚本中有一个表单,它只有一个提交按钮。单击它会刷新页面并调用我创建的函数。在函数之前,我正在回显一些文本,但它没有显示文本并转到函数并首先完成它(可能需要 10 到 20 秒)。屏幕上显示的只是按下的提交按钮。

我还有几个其他函数,它们是从以前的函数调用的,它们前面也有文本,但同样的,在所有函数完成它们正在做的事情之后,所有文本都会显示出来。

我只是不希望用户单击认为什么都没有发生的事情,因此文本只是该过程正在运行的简介。

我错过了什么吗?这是 PHP 还是表单的东西。

谢谢

                <?php
    
    if(isset($_POST["section"]) && $_POST["section"] == "Install") {
        echo "<p class='install'>Working.......<br></p>";
        Database($db);
    }
    else {
        echo "<p class='install'>Welcome to IMS setup. Please follow the instructions and enter any information as requested for a smooth installation. If you haven't done so already edit lines 4, 5 and 6 of this file to 
        match your MySQL login credentials. DO NOT change any other setting in this file. Click Install when you are ready to start.</p>
        
        <p>
        <form action='install.php' method='post'>
        &nbsp;&nbsp;&nbsp;<input type='submit' name='section' class='button button-primary' style='width: 12%' value='Install'>
        </form>
        </p>";  
    } 

function Database($db) {

echo "In Progress";
create DB and Tables code
Populate($db);
}

填充($db){

echo "In Progress";
Enter stuff in the tables.
next table etc.
} ?>
    

标签: phpformsfunctionsubmit

解决方案


推荐阅读