我对PHP和HTML表单很陌生。我试图将下面的表单数据发送到我的PHP sendsms.php --看起来php脚本并没有从html表单中获取输入数据。
<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>这是我的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'];,
));发布于 2014-10-17 23:40:01
如果你看看你的表格:
<form action="sendsms.php" method="post" >您实际上是在对表单输入进行post,因此需要在PHP中获取$_POST参数,如下所示:
$client->account->messages->create(array(
'To' => $_POST['phone'],
'From' => "+16194523868",
'Body' => $_POST['message']
));编辑
刚刚注意到,数组声明中还有一些分号(;),这些分号仍然会破坏代码。
https://stackoverflow.com/questions/26434828
复制相似问题