Welcome Guest, Not a member yet? Register   Sign In
UPDATE not work, PLZ Help me
#5

[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:
&lt;form id="form1" name="form1" method="post" action="/admin/pageedit/&lt;?php echo $id ?&gt;"&gt;

                                    <p>
                                        &lt;input name="textfield" type="text"   value="&lt;?php echo form_prep(@$this-&gt;validation->textfield)?&gt;" size="60" />
                                    </p>
                                    <p>
                                        &lt;textarea name="textarea"&gt;&lt;?php echo form_prep(@$this->validation->textarea)?&gt;&lt;/textarea&gt;
                                    </p>
                                    <p>
                                        &lt;input type="submit" name="Submit" value="Редактировать" /&gt;
                                    </p>
                                &lt;/form&gt;

Plz can you show me right way, im gone insane Smile I really want to make it work


Messages In This Thread
UPDATE not work, PLZ Help me - by El Forum - 06-12-2010, 08:57 AM
UPDATE not work, PLZ Help me - by El Forum - 06-12-2010, 09:07 AM
UPDATE not work, PLZ Help me - by El Forum - 06-12-2010, 10:00 AM
UPDATE not work, PLZ Help me - by El Forum - 06-12-2010, 10:28 AM
UPDATE not work, PLZ Help me - by El Forum - 06-12-2010, 11:42 AM
UPDATE not work, PLZ Help me - by El Forum - 06-12-2010, 11:59 AM
UPDATE not work, PLZ Help me - by El Forum - 06-12-2010, 01:16 PM
UPDATE not work, PLZ Help me - by El Forum - 06-12-2010, 01:40 PM
UPDATE not work, PLZ Help me - by El Forum - 06-12-2010, 01:46 PM
UPDATE not work, PLZ Help me - by El Forum - 06-12-2010, 01:50 PM
UPDATE not work, PLZ Help me - by El Forum - 06-12-2010, 01:52 PM
UPDATE not work, PLZ Help me - by El Forum - 06-12-2010, 02:15 PM



Theme © iAndrew 2016 - Forum software by © MyBB