我写了一个插入我的数据库的函数。我有一点疑问。
我的以下代码是否提供了良好的安全性来在将数据提交到我的数据库之前对其进行转义?
如果以下代码没有提供将数据插入 db views.php 的好方法,请为此建议我一些解决方案
<? echo form_open('Setups/subject'); ?>
<? echo '<div id="level">'. $subjectname.' : '.form_input($fsubjectname); ?>
<? echo form_submit($submitbtn);
echo form_reset($resetbtn);
echo '</fieldset>'; ?>
<? echo form_close(); ?>
控制器.php
class Setups extends CI_Controller {
function subject(){
$this->load->helper('form');
$this->load->model('Setupsmodel');
if($this->input->post('subsubmit')){
$this->Setupsmodel->entry_insert();
}
$data=$this->Setupsmodel->subjectsetup();
$this->load->view('admin/setups/subject_setups',$data);
}
}
模型.php
class Setupsmodel extends CI_Model {
function __construct()
{
// Call the Model constructor
parent::__construct();
}
function subjectsetup()
{
$data['subjectname']='Enter Subject Name';
$data['fsubjectname']=
array('name'=>'subject_name','class'=>'input','size'=>30,'id'=>'txtsubject');
$data['formtopic']='Subject Details Form';
$data['submitbtn'] = array(
'name' => 'subsubmit',
'class' => 'button',
'value' => 'Submit',
'type' => 'submit',
'content' => 'Submit'
);
$data['resetbtn'] = array(
'name' => 'button',
'class' => 'rsetbutton',
'value' => 'Reset',
'type' => 'reset',
'content' => 'Reset'
);
return $data;
}
//--------------Insertion of new record in the table subjectdetails into the db------------
function entry_insert(){
$this->load->database();
$data=array(
'subject_name'=>$this->input->post('subject_name'));
$this->db->insert('subjectdetails',$data);
}
}