title: Inserting data to database laravel
body: <p>At the moment I am working with Laravel. I am trying to insert data into a database. It is not user data, but product data. Costumers have to be able to insert a title, description and price of a product into the database.</p>
  
  <p>I have looked at the laravel website, however, I was unable to find anything. There are some people with the same question as mine on StackOverflow. However, the answers that were given to them do not work for me.</p>
  
  <p>My controller:</p>
  
  <pre><code>
  namespace App\Http\Controllers;
  
  use Illuminate\Http\Request;
  
  class ProductsController extends Controller
  {
      public function insertform(){
          return view('home');
          } 
          public function insert(Request $request){
              $productname = $request-&gt;input('title');
              $description = $request-&gt;input('description');
              $price = $request-&gt;input('price');
              $data=array('title'=&gt;$productname,"description"=&gt;$description,"price"=&gt;$price);
              DB::table('products')-&gt;insert($data);
              echo "Record inserted successfully.&lt;br/&gt;";
              echo '&lt;a href = "/insert"&gt;Click Here&lt;/a&gt; to go back.';
  }
  }
  </code></pre>
  
  <p>My view:</p>
  
  <pre><code>
  @section('content')
  &lt;h1&gt;Add your new items here:&lt;/h1&gt;
  
  &lt;form method="get"&gt;
  &lt;div class="title"&gt;
    &lt;div class="title"&gt;
      &lt;span class="input-group-text" id="title"&gt;Title&lt;/span&gt;
    &lt;/div&gt;
    &lt;input type="text" name="title" class="form-control" aria-label="title" aria-describedby="inputGroup-sizing-default"&gt;
  &lt;/div&gt;
  &lt;br&gt;
  &lt;br&gt;
  &lt;div class="description"&gt;
    &lt;div class="description"&gt;
      &lt;span class="input-group-text" id="description"&gt;Description&lt;/span&gt;
    &lt;/div&gt;
    &lt;input type="text" name="description" class="form-control" aria-label="description" aria-describedby="inputGroup-sizing-default"&gt;
  &lt;/div&gt;
  &lt;br&gt;
  &lt;br&gt;
  &lt;div class="price"&gt;
    &lt;div class="price"&gt;
      &lt;span class="input-group-text" id="price"&gt;Price&lt;/span&gt;
    &lt;/div&gt;
    &lt;input type="text" name="price" class="form-control" aria-label="price" aria-describedby="inputGroup-sizing-default"&gt;
  &lt;/div&gt;
  &lt;br&gt;
  &lt;br&gt;
    &lt;div class="form-group"&gt;
      &lt;label for="exampleFormControlFile1"&gt;Insert Image&lt;/label&gt;
      &lt;input type="file" class="form-control-file" id="exampleFormControlFile1"&gt;
    &lt;/div&gt;
    &lt;button type="submit" class="btn btn-primary"&gt;Submit&lt;/button&gt;
    &lt;/form&gt;
  @endsection
  </code></pre>
  
  <p>My web.php:</p>
  
  <pre><code>&lt;?php
  
  Route::get('/', function () {
      return view('welcome');
  });
  
  Route::get('insert','ProductsController@insertform');
  Route::post('create','ProductsController@insert'); 
  
  Auth::routes();
  
  Route::get('/home', 'HomeController@index')-&gt;name('home');
  </code></pre>
  
  <p>My database structure:</p>
  
  <p><a href="https://i.stack.imgur.com/1OhL9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1OhL9.png" alt="enter image description here"></a></p>
  
  <p>The home and welcome, along with some code in the web.php, has been made by authentication.</p>
  
  <p>Hopefuly you guys can help me out. I want to make sure that the product data is inserted into the database.</p>