Passing value from one view to another view - PHP

1

Well, I need to pass a value from one View to another View, in this case an ID. For example:

In the Main View I have a list of vacancies, when I click on one of the vacancies will load the second View where it will be possible to edit this vacancy. My question is how to pass the value of the ID of this in a correct way, without the user can modify the value in the link by inspecting through the browser.

    
asked by anonymous 15.01.2015 / 14:22

1 answer

1

In this case there is no way, what you can do is create a lock before generating the link.

For example, a hash that allows access to that id or directly the vacancy, and instead of passing the id to the generated url you pass the hash.

The page you receive finds the id of the slot through the hash.

Url example:

?vagahash=202cb962ac59075b964b07152d234b70

Sample code:

// Recebe o hash enviado, neste caso por GET
$hash = $_GET['vaga'];

// Instancia o Dao para funcoes de busca no banco de dados relacionadas a vaga
$vagaDao = new VagaDao();

// Seleciona a vaga atravez do hash
$vaga = $vagaDao->selectByHash($hash);

This way, with the hash generated by you, it is difficult for the user to modify successfully.

I hope to help you.

    
15.01.2015 / 15:29