Question: How to pass GET Parameters in encrypt format in URL using Laravel form with GET Method?

Question

How to pass GET Parameters in encrypt format in URL using Laravel form with GET Method?

Answers 3
Added at 2016-12-28 07:12
Tags
Question

I want to encrypt parameters when form submit. I am using laravel 5.2 version and when form submit that time I am using get method for submit the form. But when submit the form that time show all parameters in URL. So all this parameters I have to encrypt. For example

http://localhost:8000/get/experiences?category_id=18

to

http://localhost:8000/get/experiences/AQBBShSqt4zxsClTymwBhjIUP1kG7HEoqhoKMfAAlsMk2ZUOxStqGLAFFg0mM1nRKMEVVbB97xCvfRJTP0ZH3k1Am

How can I do this?

Answers
nr: #1 dodano: 2016-12-28 07:12

You need to define the route:

Route::post('/get/experiences/{category_id}', 'Controller@method');

After that you can make the form:

<form action="{{ url('/get/experiences/'.encrypt($category_id)) }}" method="post">
<!-- all your form data -->
<input type="submit" value="Post">
</form>

This will send a POST request to the route, /get/experiences/{category_id} and it will encrypt your $category_id using the encrypt method.

Hope this works!

nr: #2 dodano: 2016-12-28 07:12

Use encrypt() global helper to encrypt data and then decrypt() to decrypt it.

https://laravel.com/docs/5.3/encryption

nr: #3 dodano: 2016-12-28 07:12

You can use post method. Add Route::post('/get/experiences/{category_id}', 'Controller@method'); to your route and don't forget to add {!! csrf_field() !!} code within your form tags.

Parameters will not be shown in the URL so you will not have to do encryption. Of course, if you do not want to use the get method especially to encrypt.

Source Show
◀ Wstecz