【发布时间】:2016-03-13 10:01:37
【问题描述】:
我是这项工作的新手,我在视图文件夹中创建了简单的表单,如下所示:
<form action="" method="post" enctype="multipart/form-data">
<table>
<tr>
<td>Book Title</td>
<td><input type="text" name="title" /></td>
</tr>
<tr>
<td>Book Author</td>
<td><input type="text" name="author" /></td>
</tr>
<tr>
<td>Book Image</td>
<td><input type="file" name="image" /></td>
</tr>
<tr>
<td>Book Description</td>
<td><input type="text" name="content" /></td>
</tr>
<tr>
<td><input type="submit" name="submit" /></td>
</tr>
</table>
</form>
我在控制器中接收表单数据,如下所示:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Welcome extends CI_Controller {
public function index()
{
$this->load->view('insert/post');
$title = $this->input->post('title');
$author = $this->input->post('author');
$image = $this->input->post('image');
$content = $this->input->post('content');
}
}
但是如何将这些数据插入数据库,请使用简单的代码。
【问题讨论】:
-
请不要仅仅要求某人为您编码而提出问题。谷歌上有很多很多教程可以让你写得简单。那么,如果您编写的代码不起作用,请来这里寻求帮助。
标签: php codeigniter model-view-controller