[eluser]Leftfield[/eluser]
If i replace like you
Quote:<form id="form1" name="form1" method="get" action="/admin/pageedit/<?php echo $id; ?>">
then i ricive on my admin/pageedit/54 action
Quote:A PHP Error was encountered
Severity: Notice
Message: Undefined variable: id
Filename: admin/editpage.php
Line Number: 123
">
Quote:
And when i push the button Edit i ve got
Quote:An Error Was Encountered
The URI you submitted has disallowed characters.
and URL via
Quote:admin/pageedit/<div style=
Now my code look like:
Controller
Code:
function pageedit($id) {
$this->load->library('common_lib');
$this->common_lib->auth();
$this->load->helper(array('form', 'url'));
$this->load->library('validation');
$this->validation->set_rules('textfield', 'textfield', 'required');
$this->validation->set_rules('textarea', 'textarea', 'required');
//читаем запись из БД
if (!$this->input->post('textfield') && !$this->input->post('textarea')) {
$item = $this->Kernel->get($id);
$this->validation->textfield = $item['title'];
$this->validation->textarea = $item['fulltext'];
}
$data = array();
$CI = &get;_instance();
$title = $CI->config->item('admin_title');
$author = $CI->config->item('admin_login');
$data['title'] = $title;
if ($this->validation->run() == FALSE) {
$this->load->view('admin/editpage', $data);
}
else {
$data = array(
'title' => $this->input->post('textfield'),
'fulltext' => $this->input->post('textarea'),
'date' => date('Y:m:d')
);
$id = $this->input->post('id');
$this->Kernel->update($id, $data);
redirect('/admin/browsepages/');
}
}
Model
Code:
function update($id, $data) {
$this->db->where('id', $id);
$this->db->update('stand_alone_pages',$data);
}
View
Code:
<form id="form1" name="form1" method="post" action="/admin/pageedit/<?php echo $id ?>">
<p>
<input name="textfield" type="text" value="<?php echo form_prep(@$this->validation->textfield)?>" size="60" />
</p>
<p>
<textarea name="textarea"><?php echo form_prep(@$this->validation->textarea)?></textarea>
</p>
<p>
<input type="submit" name="Submit" value="Редактировать" />
</p>
</form>
Plz can you show me right way, im gone insane
I really want to make it work