Page 1 of 1
Submit multiple values to PHP
Posted: Wed Jul 04, 2007 4:13 am
by cipher#1
Hi all,
I came across this problem where i have to submit three variables from VoiceXML to PHP.
It seems like php doesn't allow it.
Could someone please tell me if it is posible to do so, and if so, how do i do it ?[/syntax]
Re: Submit multiple values to PHP
Posted: Wed Jul 04, 2007 4:17 am
by volka
cipher#1 wrote:I came across this problem where i have to submit three variables from VoiceXML to PHP.
please elaborate.
Posted: Wed Jul 04, 2007 4:28 am
by cipher#1
Well, The voice app gets a callers name, contact number, and has a chance to leave a message.
After that is done, the three variables need to be sent to php so that php can store them in a mySQL database.
The name is recorded over the fone, the contact number is being keyed in from the telephone keypad, and the message is also being recorded.
So what i want to do is submit the three variables to php and then store them in a database.
Posted: Wed Jul 04, 2007 4:57 am
by volka
The data is probably sent via http-get or http-post. php stores those parameters in the arrays $_GET and $_POST.
e.g.
http://www.w3.org/TR/voicexml/ wrote:Code: Select all
<form>
<field name="maincourse">
<prompt>
Please select an entree. Today, we’re featuring <enumerate/>
</prompt>
<option dtmf="1" value="fish"> swordfish </option>
<option dtmf="2" value="beef"> roast beef </option>
<option dtmf="3" value="chicken"> frog legs </option>
<filled>
<submit next="/cgi-bin/maincourse.cgi"
method="post" namelist="maincourse"/>
</filled>
</field>
</form>
would send a parameter
maincourse via http-post. In the receiving php script you could access this parameters as $_POST['maincourse'].
Posted: Wed Jul 04, 2007 5:21 am
by cipher#1
OK thanx.
But i need to store the three variables seperatly in the database, each variable in its own database field.
If im understanding your code right, it only sends over one variable.
In my VXML code i post the variables as:
Am i maybe doing it wrong in VXML, if not, what should be the $_POST[][] attributes in the php.
Posted: Wed Jul 04, 2007 5:23 am
by volka
<field name="maincourse">
one field, one post parameter.
If there were more fields, e.g.
Code: Select all
<field name="maincourse">...
<field name="foo">...
<field name="bar">...
then three parameters would be sent via post and php would create $_POST['maincourse'], $_POST['foo'] and $_POST['bar'] accordingly.
Posted: Wed Jul 04, 2007 5:25 am
by cipher#1
Will do.
Thanx ALOT !