I am trying to deploy a sms application which is written in PHP and I am deploying it on Heroku and using Twilio to send messages. When someone sends a message on my Twilio number, this app will send an appropriate reply to that message. I am facing a problem with switch statement in this app. I am new to coding in PHP and I am unable to get this to work. I am pasting my code below. Please help me fix it. Thank you in advance.
<?php
session_start();
header("content-type: text/xml");
switch ($answer) {
case 'headache' : {
print('OTC Crocin may help!');
break;
case 'stomachache' : {
print('OTC Tylenol may help!');
break;
case 'cough' : {
print('OTC Robitussin Cough may help!');
break;
case 'cold' : {
print('OTC Aspirin may help!');
break;
case 'vomiting' : {
print('OTC Pepto-Bismol may help!');
break;
case 'headache doctor' : {
print('Dr. Lorem Ipsum - Here is the address! Call at +1 xxx xxx xxxx');
break;
case 'stomachache doctor' : {
print('Dr. Lorem Ipsum - Here is the address! Call at +1 xxx xxx xxxx');
break;
case 'cough doctor' : {
print('Dr. Lorem Ipsum - Here is the address! Call at +1 xxx xxx xxxx');
break;
case 'cold doctor' : {
print('Dr. Lorem Ipsum - Here is the address! Call at +1 xxx xxx xxxx');
break;
case 'vomiting doctor' : {
print('Dr. Lorem Ipsum - Here is the address! Call at +1 xxx xxx xxxx');
break;
}
$from = $_POST['From'];
$answer = $_POST['Body'];
$reply = array();
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
";
?>
<Response>
<Sms>
<?php
if(is_array($reply)){
foreach($reply as $key => $value){
echo $value;
}
}
else{
echo $reply;
}
?>
</Sms>
</Response>