hey , in the login.php change action attribute of form to index.php and then in the index.php you can get the value of input boxes with $_POST , something like this :
$username = $_POST;
and process the $username and all variables like this.
I believe the best way to accomplish this is with AJAX.
Data is entered into the form and on clicking submit, instead of being taken to login.php, data is sent to login.php behind the scenes, the data is processed and returned to index.php as you wish, all seemingly in an instant without leaving index.php
I think AJAX would be a good solution too. I don’t see why you’re not just posting to index.php, check if there is $_POST data and if there is, include login.php to handle that data.
If you really want to post to login.php without using AJAX you could use session variables to set the return value/errors and redirect to index.php using the header. Then in index.php read those session variables.