I'm attempting to make an ivr system that references a foreign database (mine for this example) and then pull information from it and return it as a variable to the original post page.
Here is the code from the original ivr system - start.php
Code: Select all
<?php
header("Content-type: text/xml");
echo "<?xml version=\"1.0\"?>\n";
?>
<vxml version="2.0">
<var name="license_number"/>
<var name="request_type"/>
<var name="pin"/>
<form id="login">
<field name="pin" type="digits">
<prompt>
Please enter or say your pin.
</prompt>
<filled>
<submit next="http://hubenterprises.com.mx/test_script/pin.php" method="post" namelist="pin"/>
</filled>
<noinput>
I'm sorry, I didn't hear you. Please try again.
<reprompt/>
</noinput>
</field>
<field name="license" type="digits">
<prompt>
Please enter your license number
</prompt>
<filled>
<assign name="license_number" expr="license"/>
</filled>
</field>
<field name="request">
<grammar type="application/srgs+xml" mode="dtmf" root="choice" maxdigits="1">
<rule id="choice">
<one-of>
<item>1</item>
<item>2</item>
</one-of>
</rule>
</grammar>
<prompt>
To renew your license, press 1. To request a new license plate, press 2.
</prompt>
<filled>
<assign name="request_type" expr="request"/>
<submit next="process_request.php" method="post" namelist="
license_number request_type" fetchtimeout="60s"/>
</filled>
</field>
</form>
</vxml>
Code: Select all
<?php
header("Content-type: text/xml");
echo "<?xml version=\"1.0\"?>\n";
?>
<?php
header("Content-type: application/voicexml+xml");
$connection = mysql_connect("databasename","user","PW");
mysql_select_db("database");
$result = mysql_query("SELECT * FROM DUMMY WHERE pin = '" . $_POST["pin"]
. "'");
?>
<?
if (mysql_num_rows($result) > 0) {
$row = mysql_fetch_assoc($result);
?>
<vxml version="2.0">
<form id="login">
<field name="pin" expr="<?=$_POST['pin']?>"/>
<filled>
<if cond="pin!='<?=$row['pin']?>'">
<clear namelist="pin"/><throw event="nomatch"/>
<else/>
<submit next="http://hubenterprises.com.mx/test_script/start.php" namelist="pin" method="post"/>
</if>
</filled>
<noinput>
Error<reprompt/>
</noinput>
</field>
</form>
<?
} else {
?>
<form>
<block>
There was no pin passed in.
</block>
</form>
<?
}
?>
</vxml>
<?
mysql_close($connection);
?>
Thank you for your time