Controller 中的代码
public function store_service_provider() {
$get = file_get_contents('php://input');
$json_decode = json_decode($get,true);
foreach ($json_decode as $key => $value) {
$data[$key] = $value;
}
$data['role'] ='provider'; // assign role as provider
$record = $this->serviceprovider_model->store_service_provider($data);
if($record == '2'){
$data['json'] = json_encode(array('flag' => 'false', 'message'=> 'you have account with this email id Thank you '));
$this->load->view('jsonview', $data);
} else {
log_message("info",json_encode($record));
$message['uname'] = '<html><h1>Hi '.$record['first_name']. " " .$record['last_name'].'</h1><br\>
<h2><strong>Welcome to Look My Service.</strong></h2><br/>
<h3>Your Username: '.$record['email'].'</h3><br\>
<h2>To set your password
<a href ="'.base_url().'serviceprovider#/change_password/'.$record['id'].'">Click here </a></h2><br\>
<strong> Thank You </strong></html>';
$this->email->to($data['email']);
$this->email->subject('Hall-book');
$this->email->message(''.$message['uname'].'');
$this->email->message($this->>view('hall_service/email_message',$record,true));
$contact_number = $this->input->post("service_seeker_contact_number");
if(!$this->email->send()) {
$data['json'] = json_encode(array('flag' => 'email_error', 'message'=> ' not correct login '));
$this->load->view('jsonview', $data);
}else{
$message = 'Welcome to Look My Service. Your Username : '.$record['email'].' To set your password check you email Thank you.';
send($data['phone'], $message);
echo json_encode(array('flag' => 'true', 'message'=> 'correct login '));
}
}
}
在此输入验证码
<html>
<head>
<title></title>
</head>
<body>
<h1>sudarshan</h1>
<?php foreach($record as $record):?>
<span><?php echo $record; ?></span><br>
<h1>Hi <?=$record->first_name?> " " <?=$record['last_name']?></h1><br/>
<h2><strong>Welcome to Look My Service.</strong></h2><br/>
<h3>Your Username: <?=$record->email?></h3><br/>
<h2>To set your password
<a href ="base_url()serviceprovider#/change_password/<?=$records['id']?>">Click here </a></h2><br/>
<?php endforeach;?>
<strong> Thank You </strong>
</body>
</html>
正在将 $record 传递给 View ,在 Controller 中我可以获取所有值但在 Controller 中我无法获取 $record 的值,如何解决这个问题?如何在单击链接后禁用它
最佳答案
@aruna angadi
永远记住,当您将变量中的任何数据传递给 Controller 文件中的 View 时,您将无法在 View 文件中获得相同名称的变量名。
您只需向下一步即可获取数据。
例子:-
如果你想通过
$data = array();
$data['record'] = $my_record_data;
$this->load->view('view_file_name',$data);
然后您将使用 $record 变量获取数据。
你可以这样使用
$record
在你的 View 文件中。
谢谢
关于php - 如何将值从 Controller 传递到 codeigniter 中查看?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26339333/