2014-10-17 58 views
2

我是PHP和HTML表單的新手。我試圖發送下面的表單數據到我的PHP腳本sendms.php它似乎並沒有從PHP表單獲取輸入數據。發送HTML輸入到PHP Twilio腳本

<form action="sendsms.php" method="post" > 

     <div id="space">Cell:<div><input type="number" name="phone" id="number" ></div></div> 
     <div id="space"><div>Message</div><div><input type="text" name="message" id="message">  </div></div> 
     <div id="button"><input type="submit" name="send" value="Send" id="button" ></div> 

    </form> 

這是我的PHP文件sendsms.php

<?php 

// this line loads the library 
require('twilio-php/Services/Twilio.php'); 

$account_sid = 'REMOEVD'; 
$auth_token = 'REMOVED'; 
$client = new Services_Twilio($account_sid, $auth_token); 

$client->account->messages->create(array( 
'To' => $_POST['phone'];, 
'From' => "+16194523868", 
'Body' => $_POST['message'];, 

)); 
+0

使用了'方法=「郵報」'但試圖讀取'$ _GET',你需要使用'$ _REQUEST'或'$ _POST' – 2014-10-17 23:39:54

回答

1

如果你看看你的形式:

<form action="sendsms.php" method="post" > 

你基本上post荷蘭國際集團的形式輸入,所以你需要得到$_POST參數PHP如:

$client->account->messages->create(array( 
    'To' => $_POST['phone'], 
    'From' => "+16194523868", 
    'Body' => $_POST['message'] 
)); 

編輯

只注意到你也有數組聲明裏面的一些分號(;),它仍然會破壞你的代碼

+1

當我知道它是這樣的小東西!謝謝Kypros! – blindy 2014-10-18 00:03:18