0

In file1.php I am sending data through this code:

header("Location: file2.php? age=20");

In file2.php I am hoping to get this data through POST…

$age = $_POST['age'];

…But I not getting it. I would like to get data via POST at page2.php.

Any help would be appreciated.

Tzar
  • 4,814
  • 4
  • 20
  • 49

2 Answers2

2

If you call an URL with get-parameters you need to access this parameters also with the $_GET-method.

You access the "age"-parameter in file2.php?age=20 by

$_GET['age']

Here are two links about post and get

http://php.net/manual/en/reserved.variables.post.php http://php.net/manual/en/reserved.variables.get.php

Bernhard
  • 1,745
  • 9
  • 18
0

It is not possible to send POST data through a redirect. It is, however, possible to send POST data using cURL. See the accepted answer here for an example, and the php documentation for more info

Jonan
  • 2,514
  • 3
  • 17
  • 40