I need to use the header function in PHP to open a url, and in the process send some POST data to that site. For example, I'm using: header("Location: creatordashboard.php");
. How can I send data to that URL once it redirects? I don't want to use GET, specifically POST.
Asked
Active
Viewed 125 times
0

Jake StBu
- 31
- 4
-
See the third option here: https://stackoverflow.com/a/2604893/231316 – Chris Haas Sep 01 '22 at 01:35
-
@ChrisHaas I need it in PHP, so this doesn't really work for me. – Jake StBu Sep 01 '22 at 02:19
-
1The link above is about HTTP status code. You may use reference [here](https://www.restapitutorial.com/httpstatuscodes.html). To accept request from POST and redirect with POST, you have 2 options: 307, 308. – vee Sep 01 '22 at 02:28
-
Do you want to use POST in order to hide the data from appearing in the URL? Anyway you might find something useful in the hack mentioned here: https://www.sitepoint.com/community/t/how-to-do-redirect-in-php-with-post-and-not-get/4968/5 – Bman70 Sep 01 '22 at 04:25
-
Use [SESSION](https://www.w3schools.com/php/php_sessions.asp) for this – vatsal mangukiya Sep 01 '22 at 04:42
-
POST data is transported in the request _body_. You can't set that by manipulating the request _headers_. – CBroe Sep 01 '22 at 06:32
-
@JakeStBu - Did the answer work for you – Rohit Gupta Sep 24 '22 at 12:59
1 Answers
1
To use POST you have to submit a form. You need to use the form tags and have a button or input type=button.
If you want to use the header then you have to either pass params and use GET or use the SESSION to pass information.
If you don't want to use a form and you don't like the GET then use the SESSION.

Rohit Gupta
- 4,022
- 20
- 31
- 41