CodeIgniter Forums

Full Version: How can I use again a function for another term?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

    public function __construct() {

    public function insertPostData() {
        $data['post_title']= $this->input->post('post_title');
        $data['post']= $this->input->post('post');
        $postImg= $_FILES['post_img']['name'];
        $Img_target_file="uploads/" .basename($postImg);
            $Img_target_file="uploads/" . $data['post_img'] .basename($postImg);
        move_uploaded_file($_FILES['post_img']['tmp_name'], $Img_target_file);
//        var_dump($data);
//        die();
        $insertId= $this->HomeModel->postData('article',$data);


class HomeModel extends CI_Model {
    public function postData($table=null, $data=null) {
        return $this->db->insert_id();

I want to use my insertPostData again for my another term. how can i do that?

You could assign the values to a session variable which will be always available during the users session.
What do you mean by another term?

Do you want to use same function, but have different URL?

Or do you want same function to use different model/table?
Another term?  Huh

If you share php code, please press the PHP button on the button bar of the text editor in this forum. Paste the code between the opening and closing tag for php code.

The result will look like this:
PHP Code:
echo "Paste code in here";

So much better readable than plain text.