Retreiving form input parameters

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
deviantPsyche
Forum Newbie
Posts: 2
Joined: Thu Jan 07, 2010 3:46 pm

Retreiving form input parameters

Post by deviantPsyche »

Hello everyone,

I'm trying to retrieve all input fields (or parameters) that are being submitted from a form with a method="post". The form is not located on my server so I can't just use $_POST or $_REQUEST to get those parameters.

When using LiveHttpHeaders firefox addon and submitting an empty form on one of the site, here is the post string it shows:
firstName=&lastName=&gender=F&birthMonth=0&birthDay=0&birthYear=0&country=US&city=&zipCode=&locale=en_US&email=&password=&recaptcha_challenge_field=&recaptcha_response_field=

This string is exactly what I want, it has all the parameters like (firstName, lastName, gender etc....) in the string.

Is it possible to do something like this with php? I already tried curl post without any luck. I have tried posting empty fields from curl but all I can get is an empty string that I'm submitting when I call curl_getinfo() with curl_setopt($curl_handle, CURLINFO_HEADER_OUT, TRUE).

What I don't want is to use regex to match every form on a site (and all the input fields), it would make my life so much easier if I could just parse form action url and then extract all the necessary parameters from it.

I will greatly appreciate any help on this.
User avatar
phdatabase
Forum Commoner
Posts: 83
Joined: Fri May 28, 2010 10:02 am
Location: Fort Myers, FL

Re: Retreiving form input parameters

Post by phdatabase »

Yes. Try this. Load the form into your browser. View the page source and copy it to your editor. Save it locally. Change the action attribute to the php page of your choice where you CAN read the POST array and cookies too. Doesn't work with JavaScript though. But. You can download the JavaScript scripts and reverse engineer those too.

Or go here and follow the directions http://www.phdatabase.com/form_reader.php
Post Reply