I’m working on a simple login form and i have this redirect URL:
<form method="post" action="/incs/login.php?redirect=<?php echo $_SERVER['PHP_SELF'];?>">
but when I’m filling the form and hit the submit button I’m redirected to a wrong URL:
http://site/incs/login.php?redirect=/admin/index.php
which it’s supposed to be like this:
http://site/admin/index.php
I’m following an old guide and I have looked for this (redirect) function on the internet but I could not find anything. Does this still work now or is it not supported any more?
Just adding a query string to your URL does not do anything unless you actually use it in your server-side code. In your php script, you need to deal with the actual redirect, something like this:
The above is a big simplification, but it shows the general idea. In a real application, you would probably only redirect if the form data was valid (a successful login, for example). You would probably also want to validate the redirect URL, to make sure that it’s a valid URL in your site.
If you’re using some kind of php framework, then it’s going to handle all these details, and you just have to deal with configuring it properly.