Back

How to deal with Query string ( GET variables )


vioza posted 2 years ago

Hi Guys,

Currently working on a project that uses get variables for authentication. All things are build for internal usage.

My problem:

{{ Form::open( array("url" => "v1/verifydata?email=".$_GET['email']."&password=".$_GET['password'], "method" => "post","autocomplete" => "off","class" => "form-horizontal")) }}
<form method="POST" action="http://something.com/v1/[email protected]&password=something" accept-charset="UTF-8" autocomplete="off" class="form-horizontal"><input name="_token" type="hidden" value="rpakCpe33gS6vHTuAGPU59jrke1BQAs3skhSBwl0">
{{ Form::open( array("url" => "v1/verifydata?email=".Request::query('email')."&password=".Request::query('password'), "method" => "post","autocomplete" => "off","class" => "form-horizontal")) }}
<form method="POST" action="http://something.com/v1/verifydata?email=/[email protected]&password=/something" accept-charset="UTF-8" autocomplete="off" class="form-horizontal"><input name="_token" type="hidden" value="rpakCpe33gS6vHTuAGPU59jrke1BQAs3skhSBwl0">

How can i get the original form action: /verifydata**[email protected]&password=something** in the form open tag?

It now rewrites to all kinds of weird strings

verifydata**[email protected]&password=something**

Hope you understand en help me figure it out.

Note: i know $_GET variables are bad to use but it''s a temp solution.

Thnx

astroanu replied 2 years ago

Route::currentRouteName() will return the route. Route::input() will return an array of route params

jimgwhit replied 2 years ago

vioza said:

Note: i know $_GET variables are bad to use but it''s a temp solution.

Thnx

$_GET variables are not bad if used correctly. I see get variables on fedex site often. But not good for secure data.
Looks like you are using method="POST". If using get variables probably should be method="GET". Need a route something like:

Route::get('owners', array('uses' => '[email protected]'));

And just get the data in controller like

$yourvar = $_GET['yourpassedgetvariable'];

And no a superglobal is not bad here, the data is seen anyway in the url.
However if POST data use the laravel:

$name = Request::input('name');//way of getting post vars
loopion replied 1 year ago

While reading the API documentation, you can also do the following:

$query = $request->query();

Documentation link: https://laravel.com/api/5.3/Illuminate/Http/Request.html#method_query

soli replied 8 months ago

You can try this:

$query = $this->getQueryString();

See: https://github.com/laravel/framework/blob/5.4/src/Illuminate/Http/Request.php#L109


Sign in to participate in this thread!



We'd like to thank these amazing companies for supporting us