I'm trying to use the $_GET command in my Laravel PHP application to retrieve a value that is displayed in the URL after a user submits a form by selecting an option from a drop down menu. After the user makes their selection, the selected option is then displayed in the URL e.g.
URL before selection:
localhost:8000/pics_vids
URL after selection:
localhost:8000/pics_vids?category=tabletops
Controller:
if (isset($_GET['category']))
{
$urlcategory = $_GET['category'];
/* Additional controller code */
$data = compact('value1','value2', 'value3', 'urlcategory');
$this->layout->content = \View::make('home.picsvids.pics_vids_overview', $data);
}
View:
/*Output produces blank value instead of selected category */
<b>URL Category: {{ $urlcategory }}</b><br>
I'm not quite sure why it is appearing blank when it should return the value of the selected category. Any help is greatly appreciated, thank you!
Use the built in Input::get('name of variable here');
notation to get _GET
and _POST
variables. Should solve your problem and will certainly make your code easier to read/maintain.