0

I have a form in my PHP script which only has a submit button. When clicked it refreshes the page and calls a function that I created. Before the function I am echoing some text, but it is not showing the text and goes to the function and completes it first (which may take 10 to 20 seconds). All that shows on the screen is the depressed submit button.

I have a couple of other functions which are called from previous functions with text before them as well, but same thing, all the text shows up after all the functions have completed what they are doing.

I just don't want the user clicking on things thinking nothing is happening, so the text is just a blurb that the process is working.

Am I missing something? Is this a PHP or a form thing.

Thanks

                <?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);
}

Populate($db) {

echo "In Progress";
Enter stuff in the tables.
next table etc.
} ?>
    
  • Unless you use "server push", nothing shows on the screen until the script finishes. – Barmar Nov 30 '20 at 22:43
  • Seems like your use case would benefit from the use of [AJAX](https://developer.mozilla.org/en-US/docs/Web/Guide/AJAX/Getting_Started). – El_Vanja Nov 30 '20 at 22:44
  • @Barmar — This has nothing to do with server push (there's a obsolete and hacky approach to implementing server push called "long polling" which takes advantage of this behaviour, but that isn't what is happening here). – Quentin Nov 30 '20 at 22:44

0 Answers0