2015-07-11 27 views
2

我想提交表單後整合昂短信通知和短信發送後,我想將它重定向到我thankyou.html網頁,這是我的代碼:的Clickate - 改後的短信發送

<?php 
if(isset($_POST['send'])){ 
$query="insert into table() values() "; 
if(mysql_query($query)){ 
header("location:http://api.clickatell.com/http/sendmsg?api_id=3549342&user=xxxx&password=xxxx&to=63926475xxxx&text=xxxx "); 
} 
} 
?> 
<form method=post > 
Username: input type=text name=user > 
Password: <input type=text name=pass > 
Name: <input type=text name=name > 
Mobile number: <input type=text name=mobile_no > 
<input type=submit name=submit > 
</form> 

假設查詢返回true,它會使用clickatell api發送短信,我希望如果消息是成功的,我希望它在顯示「Thank You」的.html頁面上重定向。

我是這個api的新手,謝謝!

回答

1

爲什麼不使用file函數來檢索api url的內容?

<?php 
    $url = "http://api.clickatell.com/http/sendmsg?api_id=3549342&user=xxxx&password=xxxx&to=63926475xxxx&text=xxxx"; 

    $data = file($url); 

    $dataArr = explode(":",$data[0]); 

    if ($dataArr[0] == "OK") 
    { 
    //do the redirection here 
    header("location:your.html"); 
    exit; 
    } 
    else 
    { 
    echo "Failed: ".$dataArr[1]; //apparently $dataArr[0] contains 'ERR' and has no details regarding the error. 
    } 
?> 

你可以看到

print_r($dataArr); 

收到的全部內容這裏是鏈接到developer guide

+1

你應該從$ url變量中刪除「location:」 –

+0

@ChrisBrand謝謝你,男人。讚賞。 –

+0

我試了一下,它發送ng消息,但它重定向失敗 –