2
I have a project in Codeigniter which is in a folder within the domain. The folder structure is as follows:
/domain/Web/project/
I will call it domain and project due to the name of client/website
I can access the site in two ways: www.meudominio.com.br/project or www.projecto.com.br.
But in all the forms
I do, the variable $_POST
is empty when filled by the site www.projecto.com.br (which should be correct because the customer wishes to access as a site isolated from its root). If I fill the Forms by the site www.meudominio.com.br/project the variable $_POST
receives the data normally and I can continue with the navigation.
Is there any way I can make the two Urls receive the POST normally, as if they were one?
Follow the codes of form
and the controller, for a form
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!
For this kind of situation, where is
<b><input type="hidden" name="lojaID" id="lojaID" value="<?= @$lojaID; ?>" /></b>
, you should use it like this<?php echo @$lojaID; ?>
, then the item will be completed. If you inspect the code through theF12
Chrome will see that in the method used the value is empty, but if echo is used to print the value it assigns to html.– Marco André
Assuming Apache: you can add your own content
.htaccess
that deals with the redirect? Looks to me like you’re making one redirect without contemplating the values of$_POST
, so the form works in one location but not in the other.– Zuul