如何在表单提交后获取操作页面的URL

I have two pages lets say Page A and Page B. Page A send data on form submit to Page B as action i-e form action ="Page B". Page B does some processing and after authentication redirect user to page C if login successful or itself if login fails.

I would like to get url after processing of page B to check that whether it is in page B or redirect to Page C. Below is code for page A.

    function can_user_login($username , $password){
    echo '
        <form id = "autoSubmit" action = "Page B" method = "post" target="_blank">
            <input type = "hidden" name= "LoginForm[username]" id = "LoginForm_username" placeholder = "Enter Username" value = "'.$username.'" >
            <input type = "hidden" name= "LoginForm[password]" id = "LoginForm_password" placeholder = "Enter password" value= "'.$password.'" >
            <noscript><input type="submit" value="Click here if you are not redirected."/></noscript>
            <script type="text/javascript">
                document.getElementById("autoSubmit").submit();
            </script> 
        </form>


    ';
     //check that after submit it is at page B or redirect to Page C
}

Hope that you can understand my question and could help me get to a sollution. Thanks