Home > Software design >  How to Allow only Valid Gmail users sign up in my PHP Laravel website?
How to Allow only Valid Gmail users sign up in my PHP Laravel website?

Time:07-03

I have this my sign up form in my php Laravel site which I think hackers and robots are making unnecessary sign-ups. But now, I want to allow only Valid Gmail users to create an account. I have configured this form but users with unknown mails are able to sign up. I'm a newbie in php Laravel codes. Someone should please help me configure this to achieve the goal. Thanks in advance. See form bellow.

 @csrf
                            <div >
                                <input type="text" name="name"  placeholder="{{__('Full Name')}}">
                            </div>
                            <div >
                                <input type="text" name="username"  placeholder="{{__('Username')}}">
                            </div>
                            <div >
                                <input type="email" name="email"  placeholder="{{__('Gmail')}}">
                            </div>
                            <div >
                                <input type="tel" name="tel"  placeholder="{{__('WhatsApp Number')}}">
                            </div>
                            <div >
                                <input type="text" name="gender"  placeholder="{{__('Gender')}}">
                            </div>
                            <div >
                                <input type="text" name="item"  placeholder="{{__('What do you want to buy? Please type in your issues here')}}">
                            </div>

CodePudding user response:

Laravel have great set of email validation tools. Here you can find some detail explanation: https://minuteoflaravel.com/validation/laravel-email-validation-be-aware-of-how-you-validate/

I think that will be enough to prevent most "hackers and robots" emails.

If you still want to accept "gmail.com" addresses only, then you can use, again, laravel ends-with validator:

'email' => ['ends_with:gmail.com', ...]

If you want to be sure that they are real emails then I suggest you implement laravel email verification

For more strict verification you can also use some external services like Mailgun email verification.

CodePudding user response:

To stop bots from signing up, you can integrate a captcha service like ReCaptcha. There are multiple packages which can help you reduce the amount of code to be written. Try having a look at laravel-recaptcha package on Github.

CodePudding user response:

you can use this package for google signup https://github.com/laravel/socialite

  • Related