Welcome Guest, Not a member yet? Register   Sign In
404 when accessing a function in a controller
#1

Hi,
This is my first iteration of Codeigniter and I'm having trouble calling a function inside a controller.
I've used this tutorial more or less verbatim to set up: https://www.positronx.io/codeigniter-aut...-tutorial/
I have modified the 'welcome view' (https://example.com) with 2 buttons, 'Access' and 'Register'. 
I have 2 Controllers, 
Code:
SignupController.php & SigninController.php
In the signup controller, there are 2 public functions:
PHP Code:
public function index() 
which calls the 'form' helper and invokes the 'signup' view, and
PHP Code:
public function store() 
which verifies the input data and inserts it to the database.
The signup view contains the form html:
Code:
<form action="<?php echo base_url(); ?>/SignupController/store" method="post">
When I click the 'Register' button on the welcome page, this correctly calls the signup page: example.com/signup
But when I click the 'Submit' button of the form, example.com/SignupController/store, I get 404 File not found.
Can anyone suggest where I'm going wrong?
The Routes.php file has
PHP Code:
$routes->get('/signup''SignupController::index'); 
and I have tried to add
PHP Code:
$routes->get('/signup''SignupController::store'); 
, but it makes no difference.
Reply


Messages In This Thread
404 when accessing a function in a controller - by davecoventry - 09-11-2022, 05:48 AM



Theme © iAndrew 2016 - Forum software by © MyBB