POST is empty depending on the site I use

2

I have a project in Codeigniter that is in a folder within the domain. The folder structure is as follows:

  

/ domain / Web / project /

I'll call domain and project because of the client / site name

I can access the site in two ways: www.myspace.com/project or www.project.com .

However, in all% w_that I do, the variable forms is empty when I fill in the www.projeto.com.br site (which should be correct because the client wants access as a site isolated from its root). If I fill out the forms from the site www.mydomain.com/project the variable $_POST receives the data normally and I can proceed with the navigation.

Is there a way I can get the two URLs to receive the POST normally as one?

Here are the codes for $_POST and controller, for a form of login:

<form method="POST" action="sac/nova_conversa">
    <input type="hidden" name="lojaID" id="lojaID" value="<?= @$lojaID; ?>" />
        <p>
            <label>Nome:</label>
            <input type="text" name="nome" id="nome" />
        </p>
        <p>
            <label>Telefone:</label>
            <input type="text" name="telefone" id="telefone" />
        </p>
        <p>
            <label>E-mail:</label>
            <input type="text" name="email" id="email" />
            <input type="submit" value="Entrar" class="entrar" />
        </p>
        <?PHP if ($this->session->flashdata('errors')) { ?>
            <p class="erro"><?= $this->session->flashdata('errors'); ?></p>
        <?PHP } ?>
    </form>

Controller:

public function nova_conversa() {
    if ($_POST) {
        $data["nome"] = $this->input->post("nome");
        $data["telefone"] = $this->input->post("telefone");
        $data["email"] = $this->input->post("email");

        if (($data["nome"] == "") or ($data["telefone"] == "") or ($data["email"] == "")) {
            $this->session->set_flashdata('errors', 'Digite seus dados');
            redirect("sac");
        } else {
            $usuarioID = $this->sac_model->novo_usuario($data);

            $data["lojaID"] = $this->input->post("lojaID");
            $conversaID = $this->sac_model->nova_conversa($usuarioID, $data["lojaID"]);

            $this->session->set_userdata('chat_usuarioID', $usuarioID);
            $this->session->set_userdata('conversaID', $conversaID);

            redirect("sac/abrir_conversa");
        }
    }
}

Thank you!

    
asked by anonymous 16.06.2014 / 21:12

1 answer

1

In the file routes.php change this line:

$route['default_controller'] = "projeto";

In your config.php file, place the following:

$config['base_url'] = '';
$config['index_page'] = '';

I use the following .htaccess in the directory that is my index.php

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

My project is in this way described above, I believe that changing this way will work the same way mine works.

I noticed that the URL is case sensitive so if the site folder name is uppercase, then the URL should also be uppercase

If there is no doubt that all this configuration is correct then you can check the following, $route['default_controller'] = "projeto"; is a configuration that defines that when accessing your site the first controller to be loaded is projeto.php and method called within it will be index , if it is redirecting to another method then you should also pass your data $_POST and $_GET

In short ...

www.meudominio.com.br -> default_controller/index -> default_controller/projeto
www.meudominio.com.br/projeto -> default_controller/projeto

This is probably the explanation for your problem!

    
22.07.2014 / 15:36