首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >将数据传递给两组的问题

将数据传递给两组的问题
EN

Stack Overflow用户
提问于 2016-08-11 04:41:12
回答 1查看 105关注 0票数 2

控制器

代码语言:javascript
复制
public function searchNew()
{


    $sid = //account_sid; 
    $token = //auth_token; 
    $client = new Services_Twilio($sid, $token);

    $country = $this->input->post('select_country');
    $type = $this->input->post('type');
    $params = array(
        'Contains' => $this->input->post('contains'),
        'SmsEnabled' => $this->input->post('SMS'),
        'MmsEnabled' => $this->input->post('MMS'),
        'VoiceEnabled' => $this->input->post('Voice'),
        'ExcludeAllAddressRequired' => TRUE,
        'ExcludeLocalAddressRequired' => TRUE,
        'ExcludeForeignAddressRequired' => TRUE
    );

    $numbers = $client->account->available_phone_numbers->getList($country, $type, $params);

    return $numbers;
}

视图

代码语言:javascript
复制
<form action="<?php echo base_url('tenant/phone_numer/searhNew');?>" method="post">
<input type="text" name="contains" class="form-control mbottom1" id="user_firstname" placeholder="Enter a description name for your number">

<select name="select_country" id="select_country" class="form-control">
<option disabled selected>Country</option>
<option value="US">USA (+1)</option>
</select>

<input id="checkcap1" type="checkbox" name="Voice" class="radio1" value="True"/>Voice

<input id="checkcap2" type="checkbox"  name="SMS" class="radio1" value="True"/>SMS

<input id="checkcap3" type="checkbox" name="MMS" class="radio1" value="True"/>MMS

<input id="checktype1" type="radio" name="type" class="radio2" value="Local"/>Local

<input id="checktype2" type="radio" name="type" class="radio2" value="Mobile"/>Mobile

<input id="checktype3" type="radio" name="type" class="radio2" value="TollFree"/>Toll-Free

<input id="checktype3" type="radio" name="type" class="radio2" value="National"/>National

<button type="Submit">Test Submit</button>
</form>

我需要帮助从我的视图文件中获取$country,$type,$params。我做了一些测试,当我将$country = $this->input->post('select_country');更改为$country = "US"和其他变量为静态值时,代码运行良好,但是当我更改它们各自的输入时,我收到的错误消息是

找不到请求的资源/2010-04-01/Accounts/acount_sid/AvailablePhoneNumbers//Tollfree.json。

谢谢你的帮助。

EN

回答 1

Stack Overflow用户

发布于 2016-08-11 06:32:18

用一步一步的代码点火器流程来做。在提交表单后,在控制器中打印您的帖子数据。

代码语言:javascript
复制
print_r($_POST);

检查所有来自表单的数据。并按isset检查所有,并传入等值线、类型、类别。它将更好地工作fine..One,在twilio库中,传递的所有参数都是非常重要的。

代码语言:javascript
复制
$params=array(); 
if(isset($this->input->post('Voice'))){
   $params['VoiceEnabled']=$this->input->post('Voice');  
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38887383

复制
相关文章

相似问题

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