Laravel tutorial - Form Validation | How To Create and Validate Form in Laravel | Laravel FormRequest get input value

  • routes\web.php
  • resources\views\Form.blade.php
  • app\Http\Controllers\FormController.php

  • ·      app\Http\Controllers\FormController.php


<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class FormController extends Controller
{
    public function index(Request $request)
    {
       echo $fname = $request->input('fname');
       echo $lname = $request->input('lname');
        return;
    }
    //$request->input()
}

  • resources\views\Form.blade.php
<!DOCTYPE html>
<html>
<body>

<h2>Forms</h2>

<form action="{{ url('submit') }}" method="POST">
    @csrf
  <label for="fname">First name:</label><br>
  <input type="text" id="fname" name="fname"><br>

  <label for="lname">Last name:</label><br>
  <input type="text" id="lname" name="lname"><br><br>

  <input type="submit" value="Submit">
</form>

</body>
</html>


Laravel FormRequest get input value


Hi everyone welcome back to my dental my name is a nail in this letter will be to crypto didn't even see how we can apply the validation on its damn informed we will use the form that we made in the previous video here you can see that we have the pool facing a login button and we have a login you are also so if you do not watch this video and you don't know how to make one simple login form then you kind of want to add this video link is given in the description box so what we'll do in this video we will apply the validation functions we've enjoyed the added a mess is insure that Mrs in the pool with one in the one day be sure the old elements is wonderful all of these form and in the second baby was for the entertainment and messes with the every free. And then I will ask the question and please so forgive me because in the last video I forgot to ask the question so in this video I will ask the questions thank. So now let's stop so in the previous video remake the Estill form here. 

Other controller here and these are the cruel accounts for a leading view as well as the condolence right so for the new movie just cater to the login but I would bet and for the controller Spiegel the users that I would have been the worst method because from the extended phone we just send the post method request so now how we can just make but it is better to this season's so let's check it out how it's actually working so you can see that I need to do this is the name and password let's see 123 and something right and then we just submitted this is our token and this is I would username and password so what if we just forgot to feed 101 filled it so let's try to submit it without password now you can see that the password is not but this should not be just to go ahead because a.

 We cannot make the bus for blank so there should be some regulations and that should be of just got a message on a Billboard with the added field in order right so how we can do it so let's start with the first overall discord with the controller and make a validation function here so just to prove their dollar are cool. 

And just write a function named Benedict. And this made it a function. Really taken at A. as in but I mean this and here we can use the feed and what a validation as in at 8:00 PM keep your method right so just use here through 7 name this is unfair if you can see that. Right and the second one is username password so this film should be required. It cannot be blank anything right so. 

To simply make a note make it make it is then stream so now let's see what's actually going on here so now I'm just going to refresh it and if I just go with that the board filled again like us on mail and password is like 123 this is working fine and what if I just forgot to put his name and this would have password then we are not able to submit this form and you can see that it would just be back to this form after a fishing bait because this is not actually matching the validation criteria right so how we can just check that what is that a so for that we can just arrange it in a proper manner so also but first before let's take a look at it. Right to simply use their doughnut Adams. Like this and now let's talk to somebody.

 We got some matters yep because they just misspelled it or something. Address right now that's fine. Now you can see that the Gordon added that user is required because V. just applied a meditation on a single food so let's see we just apply the. Required fields. For the user Bossert with some fake. Yeah that's fine so now I'm just going to submit it and now you can see that we could look at it see so this is not an actual proper with that how we can show that so let's make a list 20 so let's go for the bleach and distinctive idea if you got any error if we just use it or not Addis. Yep but before that if we need to use it that it. Like this and just. 

And if also. And if like the state and it have for any function so let's check it that if we have any validations then we can just use here for each. And the. Just to use here. Colette address. All right. As an dollar E. R. R.. And just simply use here. Ally double good lyricists and just forget about our. I'm not what you are getting here. Okay so we got the OK hand at a. Why I am actually missing the spelling for. Okay so now you can see that the the added fields of added to the masses this is perfectly fine if I just put here like until then there should be only one adamis is made here you can see that password field hi this is fun so if we just put teleport fine. 

Then that's good with the Noida right so now one thing is more that that's okay we just prepared who added field but how we control these the editor messes with the let freedom like go I just want to show the user name just behind the first field and the use of possible just a blow to the user positively how we can short. Right. So for let me again just to make a little change in the court so just bring more this Adam from here and. Hey let's take a span. Just below to the. A larger field and just use it and that it added. And field name. Will be the. Username. Right and just simply use double curly braces and put hill. The dollar messes. And at the last just and it. With the. And that it. And. F.. Thank so and let's make go collateral so for these dates at Stein. 

Hello background and something like. Now you can see that you got the error message just behind them just look at the food bank so let's just take this one from head and up same thing apply on all. It was impossible to take. So now let's so does the defense yet again and now you can see that we got password field and the user name field so so let's make some debt that he had like a nail and the password is 12. 

So that's fine but here you can see that there is a one more problem that password is only the only other 2 connectors so let's see how we can apply some Max value created in the medical field and minimum boundary that'll right soul baby the north's all 4 other validations option we can use like go for the username over Max value is Dan and for the. Password of admin value is let's see 5. Right so now I'll just go back here and display had like bosses and choose the name is like on L. and Bossert is like 1 too now you can see that the boss third free user about their feet she must be at least 5 collective soul that's great if I just put here 12345 Dan this is working fine Seoul now let's see let's take the Max 12345 and older macs lentil so we just put some text and would have some.

 The medical you and here you can see that the number of men would be greater than 10 right so that survey that how we can apply the meditations and if we just use your normal things like Anand and 123456 password which is the correct answer as part of a nation then this is a little some meat so that's all all right so now I would think it's finished if you have any query you can ask in the comment box and in the interview I as I have reported that Mueller go for that duplications 1 into question is why we use this see if that I've spoken. Right and the second one is van we just got some added amasses like up this then can I just get the value from the form that you just submitted previously for example if I just make it let go. I understand. Something something this and password is 12 right so we got the address in the box but V. just north of the data that we just fill in the forms of how we can get this data back so this isn't a question and thanks for watching this video don't forget to subscribe my channel I might pick it.

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.