Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7974239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:19:00+00:00 2026-06-04T08:19:00+00:00

Basically I have two controllers using CodeIgniter for a simple blog for a project

  • 0

Basically I have two controllers using CodeIgniter for a simple blog for a project at school.
One is Home which is the login page. The other is Member for when they are signed in. in this member controller I am creating functions for add_post(), view_users_posts(), etc.
Member.php

class Member extends CI_Controller{

function __construct(){
    parent::__construct();
    $is_logged_in = $this->session->userdata('is_logged_in');
    if (!isset($is_logged_in) || $is_logged_in !== true) {
        redirect('home');
    }
}

public function index() {
    $this->load->library('pagination');

    $config['base_url'] = base_url() . 'index.php/member/index/';
    $config['total_rows'] = $this->db->get('posts')->num_rows();
    $config['per_page'] = 5;
    $config['num_links'] = 20;

    $this->pagination->initialize($config);

    $data['posts'] = $this->posts_model->get_all_posts($config['per_page'], $this->uri->segment(3));
    $this->load->view('member_view', $data);
}

public function add_post() {
    $this->load->view('add_post_view');
}

My member view has a nav menu with links to these functions like so:
member_view.php

      <li><a href="member">Home</a></li>
      <li><a href="member/add_post">Add Post</a></li>
      <li><a href="member/view_users_posts">My Posts</a></li>
      <li><a href="member/reset_pass">Reset Password</a></li>
      <li><a href="member/logout">Logout</a></li>

I haven’t finished them as I am having trouble knowing what to code. Basically if the user clicks Add Post should it refer to the function add_post in the controller which will load a view called add_post? Or should it direct to a new controller called Add_post that will load the view?

My reason is if I click add post it takes me to member/add_post but when I click back home I get member/member then add post again I get member/member/add_post.

I hope this makes sense, I am at a total loss. Thanks for any help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T08:19:01+00:00Added an answer on June 4, 2026 at 8:19 am

    you need to use base url.

    Suppsoe your base url is (in the config), http://www.example.com/

    then your code will be

    <li><a href="<?php echo base_url('member/add_post');?>">Add Post</a></li>
    

    Do the same for other items.

    Note: Remember slash in the config file. otherwise include it in base_url('/member/add_post')

    Reference

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two controllers Project and Tag, both of which have a create view
I have basically two questions. How do I locate the default Rprofile which is
I'm building this website and I have basically two questions about this page: http://sites.publishyours.com.br/silviamecozzi/pt/obra/deserto_das_palmas.php
Hi all I am using Zend framework for my PHP project. Basically I have
If I were to select a row from a table I basically have two
Basically I have two 2D points and there is a line between them. A
I have found many people with simliar issues but no soultions...basically I have two
I have two action methods that are conflicting. Basically, I want to be able
We have two separate web-apps, say 'retailUI' and 'bulkUI'. These two are basically two
So basically, I have two fast questions about kohana urls. 1) With default .htaccess

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.