发送HTML输入到PHP Twilio脚本

问题描述:

我是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

如果你看看你的形式:

<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