我已经在控制器中加载了必要的库,但是仍然面临这个问题。请检查我的代码,谢谢。放入自动加载也不起作用。
这是我的控制器:studCred
class studCred extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->library('form_validation');
$this->load->helper('form');
$this->load->helper('url');
$this->load->model('studCredModeller');
}
//Register students
public function create() {
//load registration view form
$this->load->view('studCred/Create');
//set validation rules
$this->form_validation->set_rules('username', 'Username', 'required|callback_check_username_exists');
$this->form_validation->set_rules('adminNo', 'AdminNo', 'required|callback_check_adminNo_exists');
$this->form_validation->set_rules('email', 'Email', 'required|callback_check_email_exists');
$this->form_validation->set_rules('password', 'Password', 'required');
$this->form_validation->set_rules('phone', 'Phone', 'required');
if ($this->form_validation->run() === FALSE){
$this->load->view('studCred/Create');
}
else
{
$this->studCredModeller->saveRecords();
$this->load->view('nypportal');
}
}
}
这是我的建模者:studCredModeller
<?php
if (!defined('BASEPATH'))
exit ('No direct script access allowed!');
class studCredModeller extends CI_Model
{
public function saveRecords()
{
$this->load->helper('url');
$data = array(
'username' =>$this->input->post('username'),
'admin_no' =>$this->input->post('adminNo'),
'email' =>$this->input->post('email'),
'password' => $this->input->post('password'),
'phone' => $this->input->post('phone'));
}
return $this->db->insert('stud_login', $data);
}
?>
这是我的视图:创建
<?php echo form_open('studCred/Create'); ?>
<?php echo validation_errors(); ?>
<div class="row">
<div class="col-xs-6 col-sm-6 col-md-6">
<div class="form-group">
<label>Username</label>
<input type="text" class="form-control" name="username" placeholder="Username">
</div>
</div>
<div class="col-xs-6 col-sm-6 col-md-6">
<div class="form-group">
<label>Email</label>
<input type="email" class="form-control" name="email" placeholder="Email">
</div>
</div>
</div>
<div class="row">
<div class="col-xs-6 col-sm-6 col-md-6">
<div class="form-group">
<label>Password</label>
<input type="password" class="form-control" name="password" placeholder="Password">
</div>
</div>
<div class="col-xs-6 col-sm-6 col-md-6">
<div class="form-group">
<label>Admin No</label>
<input type="text" class="form-control" name="adminNo" placeholder="AdminNo">
</div>
</div>
<div class="col-xs-6 col-sm-6 col-md-6">
<div class="form-group">
<label>Phone number</label>
<input type="number" class="form-control" name="phone" placeholder="Phone">
</div>
</div>
</div>
<input type="submit" value="Submit" name="save" class="btn btn-skin btn-block btn-lg">
<p class="lead-footer">* We'll contact you by phone & email later</p>
</form>
感谢您签出验证码!对于PHP来说,这还是很新的东西。
答案 0 :(得分:0)
谢谢,我意识到它的路径错误。