Welcome Guest, Not a member yet? Register   Sign In
Link veiws within a function
#1

(This post was last modified: 04-19-2019, 10:53 PM by Mekaboo.)

Hello all!

I have a login page that has a register button. Issue is that when I cant link the register button to my register_page.php. I keep getting 404 PAGE NOT FOUND when I have the page in my view folder. This is my code:

    public function index()
    {
        $this->load->view('welcome_message');
    
    }
    public function hello()
    {
        $this->load->view('header');
      $this->load->view("login");
          $this->load->view('footer');
    }    
    public function register()
    {
        $this->load->view('header');
      $this->load->view("register_page");
          $this->load->view('footer');
    }    

    
   
Do I have to have multiple functions or just have one? Do I use an anchor? Ive tried a different controller(Register.php) but that didnt work either. Thanks for the help.



Heart Heart ,
Mekaboo
Reply
#2

What's the link for the "Register" button?
If your controller is named "register.php" and the method is "register", then the link should be:

PHP Code:
<?= anchor('register/register','Register','class="btn"');?>

(The class option assumes you're using Bootstrap for the css lay-out; in this example it generates a hyperlink, which is styled as a button).
Reply
#3

(04-20-2019, 03:00 AM)Wouter60 Wrote: What's the link for the "Register" button?
If your controller is named "register.php" and the method is "register", then the link should be:

PHP Code:
<?= anchor('register/register','Register','class="btn"');?>

(The class option assumes you're using Bootstrap for the css lay-out; in this example it generates a hyperlink, which is styled as a button).

Thank you so very much for the help and sorry to get to you so late, had other plans Smile
I realized no matter what I changed wheter it was the route or the controller, I end up with this:

404 Page Not Found
The page you requested was not found.

The only pages that load are the welcome_message.php and login.php(I linked it properly). I cant load or link any other pages in my view. Trying to figure out why?

Th
Reply
#4

(04-20-2019, 03:00 AM)Wouter60 Wrote: What's the link for the "Register" button?
If your controller is named "register.php" and the method is "register", then the link should be:

PHP Code:
<?= anchor('register/register','Register','class="btn"');?>

(The class option assumes you're using Bootstrap for the css lay-out; in this example it generates a hyperlink, which is styled as a button).

Thank you so very much for the help and sorry to get to you so late, had other plans Smile
I realized no matter what I changed wheter it was the route or the controller, I end up with this:

404 Page Not Found
The page you requested was not found.

The only pages that load are the welcome_message.php and login.php(I linked it properly). I cant load or link any other pages after that are in my view. Trying to figure out why?

Thanks again Heart
Reply
#5

Do your links work if you inject "index.php", i.e. link to "/index.php/yourcontroller/hello"?
If so, then your htaccess is not properly configured.
Reply
#6

Did you set $config['base_url'] correctly in application/config/config.php? It must have a trailing slash.
Reply
#7

When setting your base url in config.php make sure you add the ending forward slash to it.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB