2014-01-30 34 views
0

Here'is Kannel的一個服務從我的PHP文件發送短信發送短信,但無法發送短信後,用db驗證名稱。這裏是我的代碼:在使用Kannel的獲取,網址

$to=$_GET['sender']; 
$username=$_GET['name']; 

//verifying received username  
if($getusername = mysql_fetch_array(mysql_query("SELECT count(*) as count FROM tablename where username ='".$username."'", $DB))) { 
if ($getusername['count']==0) {  
     header("Location: http://localhost:13013/cgi-bin/sendsms?username=kanneluser&password=foo&to=".$to."&text=Wrong User name, Please SMS valid user name!"); 
} 
    else { 
     header("Location: http://localhost:13013/cgi-bin/sendsms?username=kanneluser&password=foo&to=".$to."&text=text here!"); 
    } 
} 

我是否以真實的方式調用URL? 非常感謝您的幫助!

+0

嘗試使用'urlencode'爲「文本」參數 – k102

+0

的價值此外,使用像'file_get_contents'使從服務器的HTTP調用。如果您使用位置重定向,則HTTP調用將從客戶端瀏覽器進行。 – pilsetnieks

回答

1

要通過get-url自動重放,只需在您的if循環中使用echo即可,無需調用kannel的send url api。

if ($getusername['count']==0) {  
    echo "Wrong User name, Please SMS valid user name!"; 
} 
else { 
    "text=text here!"; 
}