首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将HTML输入发送到脚本

将HTML输入发送到脚本
EN

Stack Overflow用户
提问于 2014-10-17 23:37:28
回答 1查看 717关注 0票数 2

我对PHP和HTML表单很陌生。我试图将下面的表单数据发送到我的PHP sendsms.php --看起来php脚本并没有从html表单中获取输入数据。

代码语言:javascript
复制
 <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文件

代码语言:javascript
复制
<?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'];, 

));
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-10-17 23:40:01

如果你看看你的表格:

代码语言:javascript
复制
 <form action="sendsms.php" method="post" >

您实际上是在对表单输入进行post,因此需要在PHP中获取$_POST参数,如下所示:

代码语言:javascript
复制
$client->account->messages->create(array( 
    'To' =>  $_POST['phone'], 
    'From' => "+16194523868", 
    'Body' => $_POST['message']
));

编辑

刚刚注意到,数组声明中还有一些分号(;),这些分号仍然会破坏代码。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26434828

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档