Jump to content

How to capture incoming Post data from html page.


Go to solution Solved by Ch0cu3r,

Recommended Posts

when I send a <form "get"> to another page i know to capture it with

$dog = $_GET['dat'] but i need to know the variables..no problem I can see them in the URL..

 

But the question is what do I use to caputre the entire incoming post so i ca separated the variable from the data..

I also know that I can get one of the incoming variable with

$cat = $_POST ['dat']  but I need the entire unknown huge post string to come in and get broken out as follows.

 

$dog = "pet"

$horse = "four legs"

 

can someone help me... grab the entire post when it comes and break it down to varialbes and data

even when I have no idea what the variables or data will look like..

 

Thanks

 

That can be done very easily, but it is a bad idea. If you just automatically create variables based on what is sent via POST/GET you are opening your application up to huge vulnerabilities. If you don't know what data is being sent and you create variables for it, how do you know how to use those variables? Perhaps you can give an explanation of what the situation is and what you are trying to accomplish. Because, what you are asking, doesn't seem realistic.

  • Like 1
  • Solution

 

grab the entire post when it comes and break it down to varialbes and data

It already is. All data from the POST request is stored in the $_POST superglobal variable.

 

To see the contents of $_POST use print_r (or var_dump)

printf('<pre>Contents of $_POST %s</pre>', print_r($_POST, true));
  • Like 1

I agree, use the data already in the array and do checks on them.

 

Usually when you write a script you want to know the parameters and data type to expect and should be checking for that.

 

You want to do a check something like this.

if(isset($_GET['dog']) && trim($_GET['dog']) != '') {
$dog = trim($_GET['dog']);
} else {
$dog = '';
}

If you loop through the array and make them variables.....is a bad idea because anyone can write a new GET parameter in the url and compromise your code, can overwrite a variable already had.

 

terrible idea, don't do this

whatever the key is would become a variable

foreach($_GET as $key => $value){

$$key = $value;

}

if($dog){

echo $dog;

}

  • Like 1

Thanks Ch0cu3r

that was perfect.. exactly what I wanted.. you saved me several hours as I had already begun to go to each <input box and grab the name so that I could set up a post to receive that name.. wow .. that was a mistake there were over 500 variables.. wow.. so that printed the variable name and the value perfectly.... thanksagain..

Thanks Psycho for the warning.. would have been valuable to a beginner who did not know that.. but what I am doing is a one time closed capture of the "names" and initial data... before setting up to recevive the name and data in a normal post... so thanks for your input...I am sure you would have been able to answer had I been a little more clear...

 

all you guy have been great...

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.