0

There is a php web page that i want to submit my POST request but i don't know the name of the parameter. Is there a way to find out the name of the parameter that i should submit my values into.

Update: I don't have the form that submit to that page. So i can't use $_POST.

  • 1
    Why would you want to post if you don't even know what the receiving page is expecting? Sounds like you want to spam and can't be bothered to analyze the form. – jeroen Aug 20 '14 at 16:36

3 Answers3

3

You can get the names of all passed $_POST parameters with:

$parameter_names = array_keys($_POST);

If you know there is only one parameter, to get the value use:

$value = $_POST[array_keys($_POST)[0]];
Halcyon
  • 57,230
  • 10
  • 89
  • 128
2

If you want to know the parameters and don't programmatically use them, you can also use print_r($_POST);

Michael Wagner
  • 1,018
  • 8
  • 20
  • 1
    This is a good suggestion. `var_dump` does a similar job, it also gives you information about the type of variable. One reason to use `print_r` over `var_dump` is that the former can print recursive structures. – Halcyon Aug 20 '14 at 16:34
  • 1
    They all do that, of course. http://3v4l.org/LIk8U The main advantage of `print_r()` IMO is readability. – Rudie Aug 20 '14 at 19:14
0

If I understand correctly, you want to submit data to a form, but don't know what keys to use to submit. As you know, you need to know them, so find the form on the website, and look at the source code for the name="whatever" parts of the relevant inputs and make a note of the string inside the quotes. Those are your key names.

user3791372
  • 4,445
  • 6
  • 44
  • 78
  • Yeah.. but thats the problem.. i can't find the form... You described my scenario. Is there anyway to do it? – Muhammad Ibraheem Aug 20 '14 at 18:29
  • It's great that the person who understood the question is sitting on a downvote, whilst the other answers are not useful with positive scores! @MuhammadIbraheem that's like asking how to walk across the street. Some journeys you have to tread by yourself. – user3791372 Aug 20 '14 at 19:03