Php codeigniter:将变量传递给加载表单的控制器
我有一个链接,当单击该链接时,它会将一个参数传递给我的控制器,并传递给如下函数: /主页/查询/54Php codeigniter:将变量传递给加载表单的控制器,php,codeigniter,Php,Codeigniter,我有一个链接,当单击该链接时,它会将一个参数传递给我的控制器,并传递给如下函数: /主页/查询/54 然后我想加载一个包含表单的视图,并收集一些输入数据 然后我想通过电子邮件将参数和表单数据发送给我自己 这是我的控制器: public function inquire($id) { $this->form_validation->set_rules('inputName', 'Name', 'required'); if ($this->form_val
- 然后我想加载一个包含表单的视图,并收集一些输入数据
- 然后我想通过电子邮件将参数和表单数据发送给我自己
public function inquire($id) {
$this->form_validation->set_rules('inputName', 'Name', 'required');
if ($this->form_validation->run() == FALSE) {
$this->load->view('client/M_inquire.php');
} else {
$this->email->from('noreply@test.com', 'System');
$this->email->to('contactus@test.com');
$this->email->subject('New Client Registration');
$this->email->message(
"Name: " . $this->input->post('inputName') . "<br />" .
"Phone: " . $this->input->post('inputPhone') . "<br />" .
"Email: " . $this->input->post('inputEmail') . "<br />" .
"Nurse profession: " . $this->input->post('inputProfession') . "<br />" .
"Nurse ID: " . $nurseid
);
$this->email->send();
$this->load->view('client/M_inquire_success.php');
}
}
公共函数查询($id){
$this->form_validation->set_规则('inputName','Name','required');
如果($this->form\u validation->run()==FALSE){
$this->load->view('client/M_inquire.php');
}否则{
$this->email->from($this)noreply@test.com","系统",;
$this->email->to($this)contactus@test.com');
$this->email->subject(“新客户注册”);
$this->email->message(
“名称:”.$this->input->post('inputName')。“
”。
电话:“.$this->input->post('inputPhone')。”
。
“电子邮件:“.$this->input->post('inputEmail')。”
”。
“护士职业:“.$this->input->post('inputprofessional')。”
”。
“护士ID:”.$nurseid
);
$this->email->send();
$this->load->view('client/M_inquire_success.php');
}
}
我的看法是:
<?php echo form_open('home/inquire'); ?>
<label>Full Name</label>
<input type="text" name= "inputName" id="inputName">
全名
问题是控制器需要一个参数,因此当窗体打开时,它会崩溃。你知道我该如何维护我传递的第一个参数,并收集一些表单数据和电子邮件吗
非常感谢。在调用
表单_open
时,您可以在视图中附加id
因此,在您的控制器中,您可以有如下内容:
...
if ($this->form_validation->run() == FALSE) {
$data['the_id'] = $id;
$this->load->view('client/M_inquire.php', $data);
} else {
...
然后在视图中,您有:
<?php echo form_open('home/inquire/' . $the_id); ?>
在您对
表单的调用中_open
在您的视图中,您可以附加id
因此,在您的控制器中,您可以有如下内容:
...
if ($this->form_validation->run() == FALSE) {
$data['the_id'] = $id;
$this->load->view('client/M_inquire.php', $data);
} else {
...
然后在视图中,您有:
<?php echo form_open('home/inquire/' . $the_id); ?>
。这么简单,我不知道我怎么会错过它。非常感谢!明亮的这么简单,我不知道我怎么会错过它。非常感谢!