1. It seems you want user to enter username/password and upon submit then take them to index.php, right? Why don't you use <form> tags in html to achieve this?
2: You would have to use session variables for that purpose, http://www.tizag.com/phpT/phpsessions.php
You can use this tutorial to set session variables and then on the start of index.php add:
This would redirect users who haven't logged in back to weblogin.php
BTW you should always use separate thread for each problem.