Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

276
Visualizações
Form action url not working in codeigniter

I am trying to use url in form action without using form helper in codeigniter but it's not working.

<form method="post"  action="<?php echo base_url().'test'; ?>">
<form method="post"  action="/main_controller/test">

controller function

public function test(){
    echo "test function";
}

the error I am getting

http://prntscr.com/eyzhdd

about 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

It should be

<form method="post"  action="<?php echo base_url()?>index.php/main_controller/test">

as well base_url() should define as(application/config/config.php)

https://stackoverflow.com/
                        ^ on the end

$config['base_url'] = 'https://stackoverflow.com/'; # Line 26 if version 3.0+

<?php echo base_url()?>index.php/main_controller/test
              ^            ^           ^           ^
           base URL      index Controller Name   Method name

Check out the Codeigniter documentation.

about 4 years ago · Santiago Trujillo Relatório

0

<form method="post"  action="<?php echo base_url().'/main_controller/test/'; ?>">

Use Like this and define base url in http://www.example.com/ config.php file

about 4 years ago · Santiago Trujillo Relatório

0

In order to use base_url(), you must first have the URL Helper loaded. This can be done either in application/config/autoload.php (around line 67):

$autoload['helper'] = array('url');

Or, manually in controller:

$this->load->helper('url');

Then change

<form method="post"  action="<?php echo base_url().'test'; ?>">  

to

<form method="post"  action="<?php echo base_url()?>index.php/main_controller/test">

Finally add base url in application/config/config.php. For instance,

$config['base_url'] = 'http://example.com/';

By default, the index.php file will be included in your URLs: You can remove index.php from action url with .htaccess file. Please read documenation

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda