Codeigniter에서 양식 페이지를 볼 수 없습니다. 열려고합니다.Codeigniter에서 양식 페이지를 볼 수 없습니다.
form.php 이것은 Codeigniter의 내보기 파일입니다. 저는 Codeigniter에서 초보자입니다.이 문제를 해결할 수 없습니다.
<!DOCTYPE html>
<html>
<head>
<link href="<?php echo base_url().'assets/bootstrap.min.css'; ?>" rel="stylesheet" type='text/css'>
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<style>
.error{color:red}
</style>
</head>
<body>
<div class="row">
<div class="col-md-3"></div>
<div class="col-md-3">
<h1>Student Registraion</h1>
<?php
echo form_open();
echo form_label('First Name');
$data=[
'name'=>'fname',
'class'=>'form-control',
'id'=>'fname',
'value'=>isset($dta['fname'])?$dta['fname']:''
];
echo form_input($data);
echo form_error('fname');
echo form_label('Last Name');
$data=[
'name'=>'lname',
'class'=>'form-control',
'id'=>'lname',
'value'=>isset($dta['lname'])?$dta['lname']:''
];
echo form_input($data);
echo form_error('email');
echo form_label('Email');
$data=[
'name'=>'email',
'class'=>'form-control',
'id'=>'email',
'value'=>isset($dta['email'])?$dta['email']:''
];
echo form_input($data);
echo form_label('Mobile Number');
$data=[
'name'=>'mobile',
'class'=>'form-control',
'id'=>'mobile',
'value'=>isset($dta['mobile'])?$dta['mobile']:''
];
echo form_input($data);
echo form_error('mobile');
echo form_label('Message');
$data=[
'name'=>'message',
'class'=>'form-control',
'id'=>'message',
'value'=>isset($dta['message'])?$dta['message']:''
];
echo form_textarea($data).br(1);
echo form_submit('submit','submit','class="btn btn-success"');
echo form_close();
?>
</div>
<div class="col-md-3"></div>
</div>
</body>
</html>
내가 열려고하면 CodeIgniter의에서 양식 페이지를 볼 수 없습니다 home.php.
삽입 양식을 열면 오류가 발생하며 오류 스크린 샷이 첨부되었습니다.
<?php
class home extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->load->model('select');
$this->load->helper(array('form','url','html'));
$this->load->library(array('form_validation','session'));
}
function records()
{
$ytl['dta']=$this->users->datas();
//$this->load->view('info',$ytl);
//echo "<pre>controller";print_r($ytl);
}
function primezone()
{
$ytl['dta']=$this->users->datas();
echo "<pre>controller";print_r($ytl);
}
function form($id)
{
//die($id);
if($this->input->post())
{
//echo"<pre>";print_r($this->input->post());die;
$this->form_validation->set_rules('fname','First Name','required|min_length[5]');
$this->form_validation->set_rules('lname','Last Name','required|callback_check_picture[lname]');
//$this->form_validation->set_rules('email','Email','required');
$this->form_validation->set_rules('mobile','Mobile Number','required|callback_valid_phone_number[mobile]');
$this->form_validation->set_error_delimiters('<h1 class="error">', '</h1>');
if($this->form_validation->run()==True)
{
$data=[
'fname'=>$this->input->post('fname'),
'lname'=>$this->input->post('lname'),
'email'=>$this->input->post('email'),
'mobile'=>$this->input->post('mobile'),
'message'=>$this->input->post('message'),
];
$ytl=$this->select->insertdata($data);
if($ytl)
{
$this->session->set_flashdata('message', 'Successfully Added.');
redirect('home');
}
}else
{
//$this->load->view('form');
}
}
$ytl['dta']=$this->select->getDataById($id);
//echo "<pre>";print_r($ytl);die;
$this->load->view('form',$ytl);
}
public function check_picture($a){
if(!is_numeric($a))
{
return true;
}else{
$this->form_validation->set_message('check_picture', 'Please enter only char value');
return False;
}
}
function valid_phone_number($value)
{
$value = strlen($value);
//echo $value;die;
if ($value == 10) {
return true;
}
else
{
$this->form_validation->set_message('valid_phone_number', 'Mobile number not in range'); //{10}
return false;
}
}
public function index()
{
//load the database
//$this->load->database();
//load the model
$this->load->model('select');
//load the method of model
$data['h']=$this->select->select();
//return the data in view
$this->load->view('fetch_view', $data);
}
}
?>
select.php는
이 내 모델입니다. Codeigniter에서 양식 페이지를 볼 수 없습니다. 열려고 시도합니다.
<?php
class select extends CI_model
{
function __construct()
{
// Call the Model constructor
parent::__construct();
$this->load->database();
}
function datas()
{
$pzi=[
'name'=>'pratibha',
'email'=>'[email protected]',
'mobile'=>998858585,
'address'=>'noida'
];
return $pzi;
}
function insertdata($data)
{
$this->load->database();
return $this->db->insert('student',
$data);
}
public function select()
{
//data is retrive from this query
$query = $this->db->get('student');
return $query;
}
function getDataById($id)
{
$this->db->select('*');
$this->db->where('id',$id);
$this->db->from('student');
$query = $this->db->get()->row_array();
return $query;
}
}
?>
팁 : 항상 $ this-> load-> database();를 읽어 오는 중입니다. config/autoload.php에서 라이브러리를로드하지 않을까요? $ autoload [ 'libraries'] = array ('database'); ' – user4419336
업데이트 기능은 어디에 있습니까 ?? –