Suppose I have this script :
http://www.example.com/profile.php?uid=12345
And inside this script, there’s a send message feature which is handled by sendmessage.php. What sendmessage.php actually does is to INSERT something into the database then redirect back to where user started (profile.php?uid=12345).
I tried to use header(“Location: profile.php”).
But since profile.php requires ?uid=12345 in the URL [and it’s dynamic], my redirect plan is not working.
How do I ‘pass’ the current URL. In my case ‘profile.php?uid=12345’ to sendmessage.php using the GET method. And then, once sendmessage.php has completed processing, send the user back to their own screen (profile.php?uid=12345)?
Thanks in advance.
In your
profile.php?uid=12345if you are using form to send data tosendmessage.phpthen you can have a hidden field like –
<input type="hidden" name="redirect_to" value="<?=$_SERVER['REQUEST_URI']?>">Then in
sendmessage.phpyou can useheader("Location: ".$_REQUEST['redirect_to']);‘