简体   繁体   中英

How to Allow only Valid Gmail users sign up in my PHP Laravel website?

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 class="form-group">
                                <input type="text" name="name" class="form-control" placeholder="{{__('Full Name')}}">
                            </div>
                            <div class="form-group">
                                <input type="text" name="username" class="form-control" placeholder="{{__('Username')}}">
                            </div>
                            <div class="form-group">
                                <input type="email" name="email" class="form-control" placeholder="{{__('Gmail')}}">
                            </div>
                            <div class="form-group">
                                <input type="tel" name="tel" class="form-control" placeholder="{{__('WhatsApp Number')}}">
                            </div>
                            <div class="form-group">
                                <input type="text" name="gender" class="form-control" placeholder="{{__('Gender')}}">
                            </div>
                            <div class="form-group">
                                <input type="text" name="item" class="form-control" placeholder="{{__('What do you want to buy? Please type in your issues here')}}">
                            </div>

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 .

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM