Hi
I’m trying the Conditional If passing variables from asterisk (Elastix) to phpagi and viceversa and consulting to Mysql DB, I dont know what It wrong with the code, In asterisk I do the following:
Dial 75 then dial 4 digits (pin) that code is sent to phpagi that makes a query in a Mysql DB to see if the the PIN exists in DB, depending If the PIN exists or not I create a variable for making another If conditional (this second if is not working):
This is Dialplan code:
;Test If
exten => 75,1,Answer
exten => 75,n,Read(pin,enter-password,4)
exten => 75,n,AGI(testif.php,${pin})
exten=> 75,n,NoOp(${pinName})
exten=> 75,n,NoOp(${pinNameif})
same => n,Hangup
This is agiphp code:
[b]#!/usr/bin/php -q
This the mysql table (pins)
[b]mysql> select * from pins;
±------±-----+
| name | pin |
±------±-----+
| peter | 1234 |
| joe | 4321 |
±------±-----+[/b]
This what asterisk console shows when I dial PIN: 1234, this PIN exists in the DB and the first If shows me the PIN name “peter” the second If show “pinfound”, thats ok:
– Executing [75@from-internal:1] Answer(“SIP/8000-00000086”, “”) in new stack
– Executing [75@from-internal:2] Read(“SIP/8000-00000086”, “pin,enter-password,4”) in new stack
– Accepting a maximum of 4 digits.
– <SIP/8000-00000086> Playing ‘enter-password.gsm’ (language ‘en’)
– User entered ‘1234’
– Executing [75@from-internal:3] AGI(“SIP/8000-00000086”, “testif.php,1234”) in new stack
– Launched AGI Script /var/lib/asterisk/agi-bin/testif.php
– <SIP/8000-00000086>AGI Script testif.php completed, returning 0
[color=#0000FF] – Executing [75@from-internal:4] NoOp(“SIP/8000-00000086”, “peter”) in new stack
– Executing [75@from-internal:5] NoOp(“SIP/8000-00000086”, “pinfound”) in new stack[/color]
– Executing [75@from-internal:6] Hangup(“SIP/8000-00000086”, “”) in new stack
But If I dial I PIN that is not in the DB the first If works fine shows “nopin”, but the second If shows the same message as is The PIN exists “pinfound”, I dont what is wrong with the second If:
– Executing [75@from-internal:1] Answer(“SIP/8000-00000087”, “”) in new stack
– Executing [75@from-internal:2] Read(“SIP/8000-00000087”, “pin,enter-password,4”) in new stack
– Accepting a maximum of 4 digits.
– <SIP/8000-00000087> Playing ‘enter-password.gsm’ (language ‘en’)
– User entered ‘5864’
– Executing [75@from-internal:3] AGI(“SIP/8000-00000087”, “testif.php,5864”) in new stack
– Launched AGI Script /var/lib/asterisk/agi-bin/testif.php
– <SIP/8000-00000087>AGI Script testif.php completed, returning 0
[color=#0040FF] – Executing [75@from-internal:4] NoOp(“SIP/8000-00000087”, “nopin”) in new stack
– Executing [75@from-internal:5] NoOp(“SIP/8000-00000087”, “pinfound”) in new stack[/color]
– Executing [75@from-internal:6] Hangup(“SIP/8000-00000087”, “”) in new stack
Please any Ideas?