Welcome Guest, Not a member yet? Register   Sign In
Basic 'Update Entry' Script help...


I'm working on a very basic Guestbook and I'm 90% of the way there.

However, I'd like to be able to allow Guests to edit posts. They can even edit others' posts, for now Smile

<title>Update Entry | Guestbook | CodeIgniter</title>

<style type="text/css">

body {
background-color: #fff;
margin: 40px;
font-family: Lucida Grande, Verdana, Sans-serif;
font-size: 12px;
color: #4F5155;


<h1>Welcome to the Guestbook!</h1>

<p>Edit an entry on my Guestbook.</p>


echo validation_errors('<div class="error">', '</div>');

echo '<p>&nbsp;</p>';

echo form_open('guestbook/update/');

echo form_label('What is your Name?', 'author');
echo '<br />';
echo form_input('author', '');

echo '<br /><br />';

echo form_label('Your Comments', 'comments');
echo '<br />';
echo form_textarea('comments', '');

echo '<br /><br />';

echo form_submit('mysubmit', 'Update Entry!');




<p><br />Page rendered in {elapsed_time} seconds</p>


function update()
    $this->load->helper(array('form', 'url'));        
        $this->form_validation->set_error_delimiters('<div class="error">', '</div>');
        /* Form Validation */            
        $this->form_validation->set_rules('author', 'Author', 'trim|required');
        $this->form_validation->set_rules('comments', 'Comments', 'trim|required');  
        #Input and textarea field attributes
        $data["author"] = array('name' => 'author', 'id' => 'author');
        $data['comments'] = array('name' => 'comments', 'id' => 'comments');
        if ($this->form_validation->run() == FALSE)
          $data['post'] = $this->Guestbook_model->getEntry($id);
        $data['cats'] = $this->Guestbook_model->updateEntry();

function updateEntry(){
        $data = array('author' => $this->input->post('author'),
        'content' => $this->input->post('content')

I basically want to know how to:

1) pre-fill my input fields with the existing author/comments values for that post
2) update the guestbook entry when submitted correctly.

Many thanks for any help you can give.

Messages In This Thread
Basic 'Update Entry' Script help... - by El Forum - 04-28-2010, 02:13 AM
Basic 'Update Entry' Script help... - by El Forum - 04-28-2010, 02:23 AM

Theme © iAndrew 2016 - Forum software by © MyBB