What’s the difference between POST and raw POST in PHP

Before going to description..first just check this link at glance

We can divide form submissions in three cases:

  1. Submissions with content type application/x-www-form-urlencoded
  2. Submissions with content type multipart/form-data
  3. Other submissions.

In cases 1 and 3, $HTTP_RAW_POST_DATA contains the raw post data (except if the option isalways_populate_raw_post_data is set to false, in which case $HTTP_RAW_POST_DATA is empty in case 1), i.e., the data exactly as the client (usually the browser) has sent it. In case, 1, the data has a form such as

key1=value1&key2=value2&key3[]=value3.1&key3[]=value3.2

PHP automatically parses this, so that $_POST becomes:

$_POST = array(
    "key1" => "value1",
    "key2" => "value2",
    "key3" => array("value3.1", "value3.2");
)

The contents of the raw data can also be access through php://input, even in case 1 whenalways_populate_raw_post_data is set to false. In particular,file_get_contents("php://input") gives the same data $HTTP_RAW_POST_DATA has or would have.

In case 3, in which the POST data is arbitrary, $_POST will be an empty array and$HTTP_RAW_POST_DATA will always be populated.

Case 2 is a special one. In that case, PHP will parse the data and $_POST will get the content of the fields which are not uploaded files, but php://input and $HTTP_RAW_POST_DATA will be unavailable.

To get the Raw Post Data:

<?php $postdata = file_get_contents(“php://input”); ?>

Advertisements

PHP Quick Tips

What is the difference between window.onload and document.ready ?

The ready event occurs after the HTML document has been loaded, while the onload event occurs later, when all content (e.g. images) also has been loaded.

The onload event is a standard event in the DOM, while the ready event is specific to jQuery. The purpose of the ready event is that it should occur as early as possible after the document has loaded, so that code that adds funcionality to the elements in the page doesn’t have to wait for all content to load.

PHP Coding for find your IP Address
<?php
//Gets the IP address
$ip = getenv(“REMOTE_ADDR”) ;
echo “Your IP is ” . $ip;
?>

PHP coding for Browser info..

<?php
echo $_SERVER[‘HTTP_USER_AGENT’] . “\n\n”;

$browser = get_browser(null, true);
print_r($browser);
?>

Go thru this link too.. click

CSS Tips:

To display image in center use

style=”display: block; margin: 0 auto; ”

Image Zoom like E-commerce site using multizoom.js

<script type="text/javascript" src="jquery.min.js">
</script>
<script type="text/javascript" src="multizoom.js">
</script>
<script type="text/javascript">
jQuery(document).ready(function($){
 $('#image1').addimagezoom({ 
  zoomrange: [3,3],
  magnifiersize: [300,300],
  magnifierpos: 'right',
  cursorshade: false,
  largeimage: ''
 })
})

</script>

<h3>Demo</h3>
<img id="image1" border="0" src="logo.jpg" style="width:200px;height:120px">