Welcome Guest, Not a member yet? Register   Sign In
Show just posted form entry
#1

[eluser]A83[/eluser]
I'm building a application where I want some data that have been entered in a form (and saved to a database) to be displayed on the "success" page, most important I need the id of the database entry to be passed on to the "success" page, where I will display a unique link to the specific entry.

Could anyone help me out with this please?

This is my controller as it is now:

Code:
<?php

class Greeting extends Controller {

    function Greeting()
    {
        parent::Controller();

        $this->load->helper(array('form', 'url'));
        $this->load->library('form_validation');                    
        
    }
    
    function index()
    {
    
        $this->db->where('id', $this->uri->segment(1));
        
        $this->load->library('form_validation');
        
        $this->form_validation->set_message('required', 'Måste finnas');
        $this->form_validation->set_message('min_length', 'Minst 2 bokstäver');
        $this->form_validation->set_message('xss_clean', 'Inga konstiga tecken');
        $this->form_validation->set_message('valid_email', 'Måste vara en korrekt e-post');
            
        $this->form_validation->set_rules('from', 'From', 'trim|required|min_length[2]|xss_clean');
        $this->form_validation->set_rules('from_mail', 'From e-mail', 'trim|required|valid_email');
        $this->form_validation->set_rules('to', 'To', 'trim|required|min_length[2]|xss_clean');
        $this->form_validation->set_rules('to_mail', 'To e-mail', 'trim|valid_email');
        $this->form_validation->set_rules('msg', 'Message', 'trim');

        
        if ($this->form_validation->run() == FALSE)
        {
            $data['query'] = $this->db->get('greetings');
            $this->load->view('greeting_view', $data);
        }
        else
        {
            $this->db->insert('greetings', $_POST);
            $data['query'] = ?; // here I want to send the new entry incl the database entry id to the view
            $this->load->view('confirm_greeting_view', $data);
            
        }
        
    }
    
}

Thanks in advance!


Messages In This Thread
Show just posted form entry - by El Forum - 12-30-2008, 01:54 PM
Show just posted form entry - by El Forum - 12-30-2008, 02:12 PM
Show just posted form entry - by El Forum - 12-30-2008, 02:28 PM
Show just posted form entry - by El Forum - 12-30-2008, 03:05 PM
Show just posted form entry - by El Forum - 12-30-2008, 03:38 PM



Theme © iAndrew 2016 - Forum software by © MyBB