App Overview
This is a simple 'get-a-quote' page, where the user enters in a part number, quantity desired, and any optional notes.
Prior Research I made sure to thoroughly try solutions found here on StackOverflow regarding a problem similar to mine. I tried many, including the following ( I am posting this to assure you that I tried my best before posting this question ):
( and many more, I tried ) - That being said...
Problem
I cannot get the form values posted to my PHP process page. I am POSTing using JQuery Ajax. Specifically, I can't figure out how to access the 'parts', which may, or may not, contain more than one.
Desired Outcome
To retrieve all the form data, and email it using PHP.
I don't need assistance with the emailing portion, just the form values.
The PHP handler
// Receive JSON
$json = file_get_contents('php://input');
// Converts it into a PHP object
$data = json_decode($json, true);
foreach($data as $key => $value)
{
echo $key.' value of the key is:'.$value;
}
Values POSTED
Response From PHP page
name value of the key is:Johnemail value of the key is:john@gmail.comphone value of the key is:808-333-3333<br />
<font size='1'><table class='xdebug-error xe-notice' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Notice: Array to string conversion in C:\wamp64\www\123NEW\process.php on line <i>11</i></th></tr>
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr>
<tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0006</td><td bgcolor='#eeeeec' align='right'>406152</td><td bgcolor='#eeeeec'>{main}( )</td><td title='C:\wamp64\www\123NEW\process.php' bgcolor='#eeeeec'>...\process.php<b>:</b>0</td></tr>
</table></font>
parts value of the key is:Array
Application Preview
Ideally, I would like to end up with a formatted string I can email:
Name: John
Email: john@gmail.com
Phone: 800-555-1212
Parts: 1. PartNumber:p1 -- Qty: 1 -- Notes: No notes
2. PartNumber:p2 -- Qty: 3 -- N/A
Thanks for looking. Any help would be appreciated.
Note: I am using KnockoutJS so I can leverage their 2-way data-binding. Not sure if that impacts the answer to this question.