I need to convert a JSON object that the php receive from the html form into php variable. I have two forms form1 gives the values and form2 submits them. this is where I give form2 the JSON string value
-html--javascript function-
var myObj = {
"username" : theUsername,
"name" : theName,
"surname" : theSurName,
"email" : theEmail,
"password" : thePass,
"confirmpass" : thePass2,
"dob" : theDate,
"gender" : theGender,
"age" : theAge
};
var jsonstr=JSON.stringify(myObj);
document.forms["form2"]["hide"].value = jsonstr; //form2 gets the whole string
-php- //$jstr = $_REQUEST["hide"];
//$newObj=JSON.parse(jstr);
//$name = $newObj.name;
This is what I tried, but it doesn't work
I used the post method in the html. How do I now convert it back into seperate variables in php ?
stringify()
method. – Álvaro G. Vicario Aug 17 '11 at 6:39