sandip kakade
sandip kakade

Reputation: 1356

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

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?

Upvotes: 4

Views: 7601

Answers (3)

Koray Küpe
Koray Küpe

Reputation: 736

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.

Upvotes: 0

Alexey Mezenin
Alexey Mezenin

Reputation: 163768

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

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

Upvotes: 2

Robin Dirksen
Robin Dirksen

Reputation: 3422

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!

Upvotes: 2

Related Questions