hi
can any one advice pleas with click2call php script pleas ?
the script is working when each variable sumbit by it self to $strExten=
i am trying to make some changes to click2call script make it caller friendly , i added 2 post forms
1.$areacode = $POST['areacode'];
2.$tel = $POST['tel'];
what i am trying to do is when form is submited it will submit :
$txtphonenumber = $areacode . $tel;
i am trying to post the area code and tel number to third variable so asterisk will dial it .
i lost my self with the script and the if condition statment
(not a php programer)
thanks for any advice or help & sorry for my english mistake not my native lang
script attach with my testing
<?php
$strHost = "127.0.0.1";
$strUser = "admin";
$strSecret = "amp111";
$strChannel = "local/5000@from-internal";
$strContext = "from-internal";
$strWaitTime = "30";
$strPriority = "1";
$strMaxRetry = "2";
#--------------------------------------------------------------------------------------------
#get the phone number from the posted form
#$strExten = $POST['tel'];
$strExten = $POST['txtphonenumber'];
#$strExten = $_POST['areacode'];
$txtphonenumber = $areacode . $tel;
$callNumber = $strExten;
#specify the caller id for the call
$strCallerId = "Web-".$strName . " <$callNumber>";
$length = strlen($strExten);
#if ($length == 10 && is_numeric($strExten))
if ($length == 6 or $length == 10 && is_numeric($strExten))
{
$areacode = $POST['areacode'];
$tel = $POST['tel'];
$txtphonenumber = $areacode . $tel;
$oSocket = fsockopen($strHost, 5038, $errnum, $errdesc) or die("Connection to host failed");
fputs($oSocket, "Action: login\r\n");
fputs($oSocket, "Events: off\r\n");
fputs($oSocket, "Username: $strUser\r\n");
fputs($oSocket, "Secret: $strSecret\r\n\r\n");
fputs($oSocket, "Action: originate\r\n");
fputs($oSocket, "Channel: $strChannel\r\n");
fputs($oSocket, "WaitTime: $strWaitTime\r\n");
fputs($oSocket, "CallerId: $strCallerId\r\n");
fputs($oSocket, "Exten: $strExten\r\n");
fputs($oSocket, "Context: $strContext\r\n");
fputs($oSocket, "Priority: 1\r\n\r\n");
fputs($oSocket, "Action: Logoff\r\n\r\n");
sleep(3);
fclose($oSocket);
?>
<p>
<table width="300" border="1" bordercolor="#0f0f0f" cellpadding="3" cellspacing="0">
<tr><td>
<font size="4" face="verdana,georgia" color="#000111"> calling now
</font>
</td></tr>
</table>
<p><h3><a href="javascript:history.go(-1)">Go Back</a></h3>
</p>
<?
}
else
{
?>
<p>
<br>
<br>
<form action="<? echo $_SERVER['PHP_SELF'] ?>" method="post">
</p>
<?
if(isset($POST['submit'])){
$areacode = $POST['areacode'];
$tel = $POST['tel'];
$txtphonenumber = $areacode . $tel;
$strExten = $POST['txtphonenumber'];
}
?>
<h4>Pleas select your number Form</h4>
<form action="<? echo $_SERVER['PHP_SELF'] ?>" method="post">
<select name="areacode">
<option value="0506">0506</option>
<option value=1800">1800</option>
<option value="077">077</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="02">02</option>
</select>
<input type="text" size="30" maxlength="11" name="tel"><br><br>
<center><input type="submit" value="Call Now"></center>
</form>
</td></tr>
</table>
</p>
<?
}
?>