I have a project in php 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, getting only 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'm using the following solution on the front end:
<script>
if(typeof window.history.pushState == 'function') {
window.history.pushState({}, "Hide", '<?php echo $_SERVER['PHP_SELF'];?>');
}
</script>