-6

Possible Duplicate:
Getting an array result from json_decode
JSON Decode in PHP

I need help to store some selected $_POST data into mysql. I don't know variables names, it is instant notification function from cartloom like paypal ipn.

ipn.php

<?php
$data = print_r($_POST); 

$to = "hello065-65@yahoo.com";
$subject = "My subject";
$txt = $data;

mail($to,$subject,$txt,$headers);
?>

When i used print_r($_POST);

I received below content in my email..

order: {"billingFirstName":"sachin","billingLastName":"gupta","billingCompany":"df","billingAddress1":"33","billingAddress2":"","billingCity":"Chandigarh","billingState":"CT","billingPostalCode":"44444","billingCountry":"US","billingEmail":"hello065-65@yahoo.com","billingPhone":"","shippingFirstName":"","shippingLastName":"","shippingCompany":"","shippingAddress1":"","shippingAddress2":"","shippingCity":"","shippingState":null,"shippingPostalCode":null,"shippingCountry":null,"date":"Wed Apr 11 15:18:40 EDT 2012","transid":497070762,"invoice":1012,"grandTotal":"$0.00","payMethod":"none","comments":"","cartContents":[{"id":"48401","title":"Alex & Me - 10% Coupon","options":"","qty":"1","price":"0.00"}],"subTotal":"$0.00","discountAmount":"$0.00","discountTitle":"Complimentary Order","salesTaxTitle":"CT Sales Tax","salesTaxAmount":"$0.00","shippingTitle":null,"shippingAmount":"$0.00"}<br> 

Can anyone help me, how to store billingFirstName sachin data into mysql..

Community
  • 1
  • 1
sachin
  • 7
  • 3
  • Formatting your code and data sure makes a difference. We put effort into our answers for you, please put some effort into your questions for us. – Blake Apr 12 '12 at 18:51
  • Please have a look at the [FAQ](http://stackoverflow.com/faq) on how to ask a good question, and also maybe read this: [What have you tried?](http://mattgemmell.com/2008/12/08/what-have-you-tried/) – eaj Apr 12 '12 at 18:52
  • Sorry guys, i am trying to store data posted via instant notification – sachin Apr 12 '12 at 19:01

1 Answers1

2

It looks like JSON to me

you could try..

$order_details = json_decode($_POST['order']);
$the_variable_you_want = $order_details['billingFirstName'];

Edit: Updated the example to more clearly show you how to get the variable you want.

Dale
  • 10,384
  • 21
  • 34