I'm slightly new to PHP and I'm having some trouble with my PHP code. I'm sending three variables(2 voice recordings & a number) from a VXML form to my PHP, which I then want to deposit the recordings into relevant wav files and update a mysql database with the directory path of the wav files and the number from the vxml.
Here's my PHP code:
Code: Select all
<?php
header('Content-type: application:voicexml+xml; charset=iso-8859-1');
header('Content-Encoding: iso-8859-1');
echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n";
echo "<vxml version=\"2.1\" xmlns=\"http://www.w3.org/2001/vxml\" xml:lang=\"en-GB\">";
echo "<property name=\"inputmodes\" value=\"dtmf\"/>";
echo "<form>";
echo "<block>";
$msg = "";
$msg2 = "";
$code = 1;
$wavName = "";
$wavAudition = "";
$number = "";
$tmpName=$HTTP_POST_FILES['rec_name']['tmp_name'];
if (is_uploaded_file($tmpName)) {
$wavName = "///Auditions/name/".date("YmdHis").".wav";
copy($tmpName, sprintf("%s", $wavName));
$msg = "audio saved";
echo "saved name";
} else {
$code = 0;
$msg = "unable to save audio";
echo "not saved";
}
$tmpAudition=$HTTP_POST_FILES['rec_audition']['tmp_name'];
if (is_uploaded_file($tmpAudition)) {
$wavAudition = "///Auditions/audition/".date("YmdHis").".wav";
copy($tmpAudition, sprintf("%s", $wavAudition));
$msg2 = "audio saved";
echo "saved audition";
} else {
$code = 0;
$msg2 = "unable to save audio";
echo "not saved";
}
$tmpNumber = $_POST['contact_number'];
if (is_uploaded_file($tmpNumber)) {
copy($tmpNumber, sprintf("%s", $number);
}
$con = mysql_connect("[i]local host[/i]","[i]username[/i]","[i]password[/i]");
if (!$con) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("[i]database name[/i]", $con);
$callDate = date("Ymd");
$callTime = date("His");
$sql="INSERT INTO Caller (calContactDir, calContactNum, calAuditionDir, calDate, calTime)
VALUES
('$wavName','$number','$wavAudition', '$callDate', '$callTime')";
if (!mysql_query($sql,$con)) {
die('Error: ' . mysql_error());
}
$sql="SELECT calUniqueID FROM Caller WHERE calContactDir = '$wavName'";
$uniqueID = mysql_query($sql,$con);
mysql_close($con);
echo "<audio src=\"file:///170.wav\" maxage=\"0\"/>";
echo "<prompt>$callDate</prompt>";
echo "<audio src=\"file:///171.wav\" maxage=\"0\"/>";
echo "<prompt>$uniqueID</prompt>";
echo "<goto next=\"file:///Audition_test.vxml#closing\"/>";
echo "</block>";
echo "</form>";
echo "</vxml>";
?>Code: Select all
<submit next="submit.php" namelist="rec_name rec_audition contact_number" enctype="multipart/form-data"/>The audition variable gets saved in a wav file, but not the name variable. Also, I have to comment out the tmpNumber section otherwise I get a "NOT ALLOWED IN PROLOG"
Please ignore the parts of the code in italics (I have to remove that data for business reasons).
If anyone could shine some light on this, it would be greatly appreciated.
Thanx!