That's just what Chrome is showing you, PHP is not creating and sending that page to the browser. It's probably doing that because there is a 500 response from the server, which means a server error, which means there will be an actual error message somewhere if you have it configured correctly and know where to look.

At first, we retrieved the file from the temporary location and we opened it in reading mode.

Using the while loop, we stored the values from the excelsheet rows as indexed arrays to some variables.

Finally, we added those variables in the insert query and executed while remaining inside the loop. That makes the function run until the last row of excelsheet and insert each of those rows individually in database.

Once completed, you can store a success message in session and display it to the user while redirecting the user.