Redirect after script PHP, how to do?

Need to do a redirect after execution of the script. Ie index.php sends to another file after the form is submitted POST'ω, where processing the form, after which it would be nice to return to the original page. I understand that
header('Location:' . __DIR__ . '/index.php');
but the problem is that index.php then does not display the changed information.
Question 2, bonus. How adequate is the use of JavaScript, the lateral window.location.href? (which, by the way, once hung from the server during the test :D)
June 26th 19 at 13:58
1 answer
June 26th 19 at 14:00
First, redirect need to specify the path on the website, not the server.
header('Location: /index.php');

Second, if processing a few seconds, the handle should be in the same script, and then redirect to the result.
If the treatment is very long, it is necessary to write to the queue processing and display the "your request has been accepted and is being processed." A separate daemon or the cron processing of the queue and through the web socket to output the result to the client.
Thanks, it works =) But I was more inventive, appeared circular redirect ERR_TOO_MANY_REDIRECTS, because I did include the script handler on index.php.


And in about ways: where to read when to use __DIR__, and when not to? I with the server part of a week to understand, difficult to understand when you need absolute, and when relative path =) - jerrell89 commented on June 26th 19 at 14:03

To begin, start to determine the difference between the path to the North and the url in the browser address bar.

These are different things and they may not match at all. - Tianna15 commented on June 26th 19 at 14:06
: i.e. if you specify a path for a file to some script - use an absolute path with__DIR__, in the case of specifying the address of the site (the html file) to the script, which should be a mapping of this file to a user - relative path is used and this constant is superfluous. Do I understand correctly?

Just "different things" is for the user, in fact I take it as files on the server (what they are), hence the complexity in understanding. - jerrell89 commented on June 26th 19 at 14:09

if you specify a site address (the html file) to the script, which should be displaying this file to the user used a relative path and this constant excess

Almost true.

Try to read a little about CNC. There's a difference between url and file path on the server clearly seen

For example the URLs :

The server can be configured so that all will be treated the same to your script. - Tianna15 commented on June 26th 19 at 14:12

Find more questions by tags PHP