[Solved] POST data from input within loop


There is no need of using a form to accomplish what you want.

@foreach($images as $image)
  <div class="card" >
    <div class="card-inside1" >
        <div class="center">
          <img clas="card-img-top img-fluid" src="https://stackoverflow.com/questions/48009725/<?php echo asset("images')."https://stackoverflow.com/".$image->image1 ?>" alt="Card image" >
        </div>
        <div class="card-body">
          <input type="text" name="imagename" value="{{$image->product_name}}"></input>
            <a href="{{url('details/'.$image->product_name)}}" class="btn btn-primary ">More</a>
        </div>
    </div>
  </div>
@endforeach

Route:

Route::get("details/{imagename}",'UserController@detail');

Controller:

public function detail(Request $req)
{
   $productname = $req->imagename;
   return $productname;
}

UPDATE

The reason why is taking the last product is because you are sending all products through the form. and it takes the last one that sends, not the one you clicked.

0

solved POST data from input within loop