Noré_the_lucky
Noré_the_lucky

Reputation: 5

Submit form using Codeigniter URI Routing not work

I have to update a site, that i did not create, with a forum. The site is create with codeigniter's last version. I'm a newbie in routing uri.

When I submit my form, I have an error "404 The page you requested was not found". The method add_post() that I want to execute is in the Class Admin_adherent_forum_C. This class is in the controllers/admin_adherent folder. There's something wrong with the route but I don't know what?

HTML :

<form action="<?=base_url('espace-adherent/forum/creer_sujet.html')?>" method="post" enctype="multipart/form-data">
      <div class="CreateSubjectHeader">
        <p>Nouveau sujet</p><a href=".CreateSubject" id="openButtonSubject">+</a><a id="closeButtonSubject">-</a>
      </div>
      <div id="contentSubject">
        <div class="CreateSubject">
          <div class="CreateSubjectTitle">
            <label>Titre :</label>
            <input type="text" name="sujet" value="" required>
          </div>
          <div class="CreateSubjectContent">
            <label>Texte :</label>
            <textarea name="discussion" required></textarea>
          </div>
          <div class="CreateSubjectCategory">
            <label>Catégorie :</label>
            <select id="selectCategory" class="categorie" name="categorie[]" multiple>
              <option value="1">Entreprise</option>
              <option value="2">Collaborateurs</option>
              <option value="3">Recyclage</option>
              <option value="4">Valorisation</option>
              <option value="5">Aménagement</option>
            </select>
          </div>
        </div>
        <div class="CreateSubjectFooter">
          <img class="FileIcon" src="/img/file_icon.svg" alt="">
          <input id="file" class="FileInput" type="file" name="fichier_sujet" value="">
          <input class="SubmitButton" type="submit" name="publier" value="Publier">
        </div>
      </div>
    </form>

PHP :

defined('BASEPATH') OR exit('No direct script access allowed');

  class Admin_adherent_forum_C extends CI_Controller {
   public function add_post()
    {
      my code here...
    }
  }

ROUTES :

$route['espace-adherent/forum/creer_sujet']= 'admin_adherent/Admin_adherent_forum_C/add_post';

Upvotes: 0

Views: 152

Answers (3)

Nor&#233;_the_lucky
Nor&#233;_the_lucky

Reputation: 5

Problem is solved. It comes from the .htaccess rewriting mode. I don't know how and why but it was disabled.

Upvotes: 0

Vamsi
Vamsi

Reputation: 421

In the form action the URL given in

base_url('espace-adherent/forum/creer_sujet.html')

But the URL configured in the is

$route['espace-adherent/forum/add_post']= 'admin_adherent/Admin_adherent_forum_C/add_post';

Update: Please try to remove .html from the form action.

Hope it works. Thanks

Upvotes: 0

shubham chhapre
shubham chhapre

Reputation: 296

In the form action change URL with this.

base_url('espace-adherent/forum/creer_sujet');

Upvotes: 1

Related Questions