kavi
1 year ago
146
17
Laravel

Contact form validation error

Posted 1 year ago by kavi

My html code

             ```    <!DOCTYPE html>
                            <html>
                            <head>
                            <title>Dradz</title>
        <link rel="stylesheet" type="text/css" href="/css/app.css">
        </head>
            <body>
                    @include('inc.navbar')
                <div class="container">
                @if(Request::is('/'))
                @include('inc.showcase')
                    @endif
                <div class="row">
                <div class="col-md-8 col-lg-8">
                    @yield('content')
                        </div>
                <div class="col-md-4 col-lg-4">
                @include('inc.sidebar')
                    @show
                        </div>
                </div>
                </div>
        <footer id="footer" class="text-center">
            <p>Copyright 2017 &copy; Dradz</p>
                </footer>
                    </body>
                            </html>

My codes - Route

<?php

Route::get('/', function () {
    return view('home');
});

Route::get('/about', function () {
    return view('about');
});

Route::get('/contact', function () {
    return view('contact');
});

Route::post('/contact/submit', '[email protected]');

  

Messages Controller -


namespace App\Http\Controllers;

use Illuminate\Http\Request;

class MessagesController extends Controller


{
    public function submit(Request $request){
        $this->validate($request, [
            'name' => 'required',
            'email' =>'required'
        ]);
        return 'SUCCESS';
    }
};
               ```

Contact form 

``` @extends('layouts.app')

@section('content')
    <H1>Contact</H1>
<form action="{{ route('contact.submit') }}" method="POST">
    {{ csrf_field() }}
    <div class="form-group">
        {!! Form::label('name', 'Name') !!}
        {!! Form::text('name',' ',  ['class' => 'awesome form-control', 'placeholder' => 'Enter name'] ) !!}
      </div>
      <div class="form-group">
        {!! Form::label('email', 'E-Mail Address') !!}
        {!! Form::text('email',' ' ,  ['class' => 'awesome form-control', 'placeholder' => 'Enter Email id']) !!}
      </div>
       <div class="form-group">
        {!! Form::label('messages', 'Message') !!}
        {!! Form::textarea('message','' , ['class' => 'form-control', 'placeholder' => 'Enter your message here']) !!}
      </div>
      <div>
        {!! Form::submit('Submit', ['class'=> 'btn btn-primary']) !!}
      </div>
        {!! Form::close() !!};
@endsection ```


I am getting this error
``` Action App\Http\Controllers\[email protected] not defined. (View: C:\xampp\htdocs\basicwebsite\resources\views\contact.blade.php)                      ```
and my contact form does not submit on clicking the button instead i get ```http://basicwebsite.dev/contact?_token=aWNGxdMuYY8HiDjuKYnxRDkkFPYLlmk8veim7rWN&name=+&email=+&message=``` On my url



Please sign in or create an account to participate in this conversation.