Submit multiple values to PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
cipher#1
Forum Newbie
Posts: 11
Joined: Wed Jul 04, 2007 3:58 am

Submit multiple values to PHP

Post 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]
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Re: Submit multiple values to PHP

Post by volka »

cipher#1 wrote:I came across this problem where i have to submit three variables from VoiceXML to PHP.
please elaborate.
cipher#1
Forum Newbie
Posts: 11
Joined: Wed Jul 04, 2007 3:58 am

Post 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.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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'].
cipher#1
Forum Newbie
Posts: 11
Joined: Wed Jul 04, 2007 3:58 am

Post 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.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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.
cipher#1
Forum Newbie
Posts: 11
Joined: Wed Jul 04, 2007 3:58 am

Post by cipher#1 »

Will do.
Thanx ALOT !
Post Reply