我在codeigniter中显示index.php时遇到问题。有人可以帮我这个吗?
这是我的index.php:
<form id="myForm" action="<?php echo baseurl('controller/CreateUser'); ?>" method="post">
Name: <input type="text" name="name"/><br/>
Username: <input type="text" name="username"/><br/>
Password: <input type="password" name="password"/><br/>
<button id="sub">Save</button>
</form>
<span id="result"></span>
这是我的控制器:
public function index(){
$this->load->view( 'layouts/header', [ 'title' => 'Never Stop Learning!' ] );
$this->load->view( 'NeverStopLearning/index');
$this->load->view( 'layouts/footer' );
}
public function CreateUser(){
$data = array(
"name" => $this->input->post("name"),
"username" => $this->input->post("username"),
"password" => $this->input->post("password")
);
if($this->model->Insert('table_users', $data)){
echo "Successfully Inserted";
}else{
echo "Insertion Failed";
}
}