Tagged: 5.7 buzz/laravel-google-captcha

Laravel 5.7 Google reCAPTCHA Tutorial with Example 0

Laravel 5.7 Google reCAPTCHA Tutorial with Example

Today, We want to share with you Laravel 5.7 Google reCAPTCHA Tutorial with Example.In this post we will show you Laravel 5.7 – Google Recaptcha Code with Validation, hear for PHP Laravel 5.7 Contact Form With Validation And Recaptcha we will give you demo and example for implement.In this post, we will learn about Laravel 5.7 Validate Form on Submit using Google NoCaptcha reCaptcha with an example.

Laravel 5.7 Google reCAPTCHA Tutorial with Example

There are the Following The simple About Laravel 5.7 Google reCAPTCHA Tutorial with Example Full Information With Example and source code.

As I will cover this Post with live Working example to develop Using new Google reCAPTCHA with PHP Laravel 5.7, so the How to Use reCAPTCHA in Laravel 5.7 Forms For Validation for this example is following below.

Step 1 : Install Laravel 5.7 Project

simple Laravel 5.7 version Web application

composer create-project --prefer-dist laravel/laravel atmiya25

Step 2: Install Latest anhskohbo/no-captcha Laravel Package

composer require anhskohbo/no-captcha

config/app.php

 [

         ///some providers in Laravel.....

         Anhskohbo\NoCaptcha\NoCaptchaServiceProvider::class

     ],

     'aliases' => [

         ////........some aliases

         'NoCaptcha' => Anhskohbo\NoCaptcha\Facades\NoCaptcha::class,

     ]

  ]

Step 3: Update Your Domain or Localhost in Google API Key

In this phase I simple need to set your google recaptcha-response site key as well as secret key. If you any don’t have your google-recaptcha-response site key as well as secret key then We can first of all click to create from here. So We First click on this google link : laravel 5.7 google captcha Admin Panel

setting of the .env Files

Laravel 5.7 Google reCAPTCHA GET KEY Tutorial with Example

NOCAPTCHA_SITEKEY=[google_captcha_site-key]
NOCAPTCHA_SECRET=[google_captcha_secret-key]

Step 4: Define Laravel Route

routes/web.php

Route::get('member-reg', '[email protected]');
Route::post('member-reg', '[email protected]');

Step 5: Create Laravel MemberAuthController

app/Http/Controllers/MemberAuthController.php

validate($request, [
            'name' => 'required',
            'email' => 'required|email',
            'password' => 'required|same:member_pass_repeat',
            'member_pass_repeat' => 'required',
            'g-recaptcha-response' => 'required|captcha',
        ]);
   
        print('done');
    }
}

Step 6: Create Laravel Blade View File

resources/views/MemberRegister.blade.php



	<title>Laravel 5.7 - Google Recaptcha Code with Validation - pakainfo.com</title>
	
	
	 {!! NoCaptcha::renderJs() !!}


  <h1>Laravel 5.7 - Google Recaptcha Code with Validation - Pakainfo.com</h1>
<div class="pakainfo container">
    <div class="pakainfo row">
        <div class="pakainfo col-md-8 col-md-offset-2">
            <div class="pakainfo panel panel-primary">
                <div class="pakainfo panel-heading">Sign Up - pakainfo.com</div>
                <div class="pakainfo panel-body">
                    <form class="form-horizontal" role="form" method="POST" action="{{ url('/member-reg') }}">
                        {!! csrf_field() !!}
   
                        <div>has('name') ? ' has-error' : '' }}">
                            <label class="col-md-4 control-label">Name</label>
                            <div class="col-md-6">
                                
                                @if ($errors->has('name'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('name') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>
   
                        <div>has('email') ? ' has-error' : '' }}">
                            <label class="col-md-4 control-label">E-Mail</label>
                            <div class="col-md-6">
                                
                                @if ($errors->has('email'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('email') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>
   
                        <div>has('password') ? ' has-error' : '' }}">
                            <label class="pakainfo col-md-4 control-label">Password</label>
                            <div class="pakainfo col-md-6">
                                
                                @if ($errors->has('password'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('password') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>
   
                        <div>has('member_pass_repeat') ? ' has-error' : '' }}">
                            <label class="col-md-4 control-label">Confirm Password</label>
                            <div class="pakainfo col-md-6">
                                
                                @if ($errors->has('member_pass_repeat'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('member_pass_repeat') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>
   
                        <div>has('g-recaptcha-response') ? ' has-error' : '' }}">
                            <label class="pakainfo col-md-4 control-label">Google Captcha</label>
                            <div class="pakainfo col-md-6">
                                {!! app('captcha')->display() !!}
                                @if ($errors->has('g-recaptcha-response'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('g-recaptcha-response') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>
   
                        <div class="pakainfo form-group">
                            <div class="pakainfo col-md-6 col-md-offset-4">
                                <br />
                                <button type="submit" class="btn btn-success">
                                    <i class="fa fa-btn fa-member"></i>Register
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
   


Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Laravel 5.7 Google reCAPTCHA Tutorial with Example.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.