0

I have created register and login buttons, when I click register or Login button it gets a URL like this (http://[::1]/udemy/User/registration). it should come like this only (http://localhost/udemy/User/registration) I'm new in CodeIgniter please someone helps me make this proper URL.

Below my HTML view code:

<a href="<?= base_url('User/registration') ?>" class="btn btn-info my-2 my-sm-0">Register</a> &nbsp;
                    <a href="<?= base_url('User/login') ?>" class="btn btn-success my-2 my-sm-0">Login</a>
Abdulla Nilam
  • 36,589
  • 17
  • 64
  • 85
makizhan
  • 11
  • 2

1 Answers1

-1

hi CodeIgniter routing is very simple you should define you route first like this

$route['products/([a-zA-Z]+)/edit/(\d+)'] = function ($product_type, $id)
{
        return 'catalog/product_edit/' . strtolower($product_type) . '/' . $id;
};

as you can see I define a route with path /products/{name}/edit/{id}

now We can use our rutting anyweare like this

<a href="<?=site_url('products/'.$product_name.'/edit/'.$product_id)?>">Edit Product</a>

also for get more information about routing i suggest you to see this article and this