0
I have a php project with codeigniter that gets dominio.com/?id=212454&survey=complete
and after I save this data in a variable, I wanted to remove it from the url, just getting dominio.com
My current controller looks like this:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Welcome extends CI_Controller {
public function index()
{
$parameters = $this->input->get();
if(isset($parameters['id'])){
if(filter_var($parameters['id'], FILTER_VALIDATE_EMAIL) || (preg_match("/\(?\d{2}\)?\s?\d{5}\-?\d{4}/", $parameters['id']))){
//o email ou telefone é valido
$this->load->view('index',[
'survey'=>$parameters['survey'],
]);
}else{
$this->load->view('semvariavel');
};
}else{
$this->load->view('semvariavel');
};
}
}
I am using the following solution in front-end:
<script>
if(typeof window.history.pushState == 'function') {
window.history.pushState({}, "Hide", '<?php echo $_SERVER['PHP_SELF'];?>');
}
</script>
Which web server are you using? Apache?
– bfavaretto
Pass the data by post instead of get
– Woton Sampaio
@bfavaretto yes
– Igor Oliveira
@Wotonsampaio is not possible, it will be a link type ref, the person already enters with the parameters
– Igor Oliveira
See if the content on the page I indicated as duplicate solves your problem. If not, let me know here.
– bfavaretto
@bfavaretto tried not to work
– Igor Oliveira
It’s kind of weird what you describe as wanting to do...
– bfavaretto
is a search page, I do not want the person to see her ref after entering the page
– Igor Oliveira
Maybe a PHP redirect, then?
– bfavaretto
The two possibilities are, 1. after the page load run history.pushState - 2. use Ajax and not page - Extra: of course you can also choose to use friendly Urls, which technically would still be different urls, may be what you are looking for may not.
– Guilherme Nascimento
It seems that the solution is just front end, the problem is that by doing this on the front, I’m getting url.com/index.php, but I think I can solve it with . htaccess
– Igor Oliveira