WEBVTT

00:00.650 --> 00:03.890
I will call you back again to another video lecture in PHP.

00:04.040 --> 00:09.860
In this video lecture, let's go ahead and learn how to accept input from a user in PHP.

00:16.940 --> 00:17.420
All right.

00:17.420 --> 00:20.960
So we know that PHP is a server side scripting language.

00:20.990 --> 00:28.040
Therefore it needs the client side scripting language like HTML to be able to accept input from a user.

00:28.280 --> 00:35.000
So what means is that you're going to create a HTML form where users can be able to input their username

00:35.000 --> 00:42.770
or password and so on, and then they can be able to collect these and pass in that to PHP, which is

00:42.800 --> 00:45.620
a server side scripting language, and move from there.

00:45.620 --> 00:48.020
They can move that to the database.

00:48.350 --> 00:56.630
So for us to be able to accept input from a user in PHP, it means we're going to write a small HTML

00:56.630 --> 01:03.380
code where we can be able to just create a form, because we're going to use that form to impute the

01:03.380 --> 01:04.220
user details.

01:04.250 --> 01:05.870
Let's go ahead and create a form.

01:05.900 --> 01:11.000
I'll go ahead and say form and I'll close this form.

01:12.710 --> 01:13.160
All right.

01:13.190 --> 01:22.940
Now I'm going to go right in here and give an action which is communicating with my PHP code.

01:22.970 --> 01:24.890
Let's go ahead and say action.

01:24.890 --> 01:31.910
So inside this action I'm going to tell the form, the PHP file that is going to act on the form that

01:31.910 --> 01:32.720
I'm creating.

01:32.720 --> 01:36.050
So in this case we are working on sites dot PHP.

01:36.080 --> 01:38.630
So I will say site dot PHP.

01:38.660 --> 01:44.030
That is the PHP file that is going to act on this particular form that I'm creating right now.

01:44.060 --> 01:49.790
And the word I want is to get the, uh, information from this form.

01:49.790 --> 01:51.410
So I'm going to create a method.

01:51.440 --> 01:56.570
The method is going to be a Get method because I want to get information.

01:56.570 --> 01:59.960
Therefore you are going to use a Get method.

02:00.380 --> 02:08.820
Now if we be able to give this for an action to act on this, which is the site dot PHP and they're

02:08.820 --> 02:10.200
using the method gate.

02:10.290 --> 02:13.350
Go ahead and create a simple form right in there.

02:13.350 --> 02:14.820
That is the input.

02:14.820 --> 02:16.680
So I want users to input.

02:16.680 --> 02:23.610
And the type of input I want right in here is going to be a text, because I just want you to input

02:23.610 --> 02:24.480
your username.

02:24.480 --> 02:29.730
Now I'll go ahead and say a name is going to be just username.

02:31.980 --> 02:32.400
All right.

02:32.430 --> 02:35.850
Go ahead and close this input tag.

02:35.880 --> 02:43.710
Now whenever a user inputs his or her name you're going to need a submit button to submit that input.

02:43.740 --> 02:47.880
Therefore you're going to create an A submit button.

02:47.880 --> 02:54.960
So another input tag and this time around is going to be a submit.

02:54.990 --> 02:56.940
Go ahead and create this input tag.

02:56.970 --> 02:59.550
Now let's go ahead and refresh this I check it out.

02:59.550 --> 03:05.450
So right now we have our form and we have the submit button.

03:05.480 --> 03:10.550
Now, if I go ahead and say that my name is George, and if I had to submit these, you can see that

03:10.550 --> 03:11.690
nothing happens.

03:11.720 --> 03:13.460
We are not able to see anything.

03:13.460 --> 03:16.550
I just submitted these and it went into the tint area.

03:16.580 --> 03:20.210
I need to submit these using the PHP file.

03:20.240 --> 03:28.040
Now I have to go back to my PHP right here just below here, and I'm going to type PHP to echo out,

03:28.040 --> 03:30.950
voice out, whatever that I input inside that form.

03:30.950 --> 03:32.870
So let's go ahead and say echo.

03:32.870 --> 03:39.440
And then we'll go ahead and use the dollar sign underscore get because we are using the Get method right

03:39.440 --> 03:39.920
in here.

03:39.920 --> 03:44.030
And now I'm go ahead and input the name which is the user name.

03:44.030 --> 03:48.080
So whatever name you input right in here is what I'm going to put down here.

03:48.080 --> 03:52.580
So I'll go ahead and say echo add the username I'll go ahead and save this.

03:52.640 --> 03:54.950
Now go ahead and refresh this again.

03:54.950 --> 03:59.180
And you see that the George I input before has been printed out.

04:00.110 --> 04:00.710
All right.

04:00.740 --> 04:02.450
Now let's go ahead and input another one.

04:02.450 --> 04:06.820
So I'm going to say Steve and go ahead and submit this now.

04:06.850 --> 04:08.980
Steve is now a cut out.

04:09.850 --> 04:12.790
So I basically get told to actually do this.

04:12.820 --> 04:13.600
You understand.

04:13.600 --> 04:14.530
So whatever.

04:14.650 --> 04:20.440
Whenever a user puts them right in there I'll go ahead and be able to voice that out.

04:20.440 --> 04:26.560
You can see that my PHP is now communicating with the, uh, the form I created.

04:26.590 --> 04:29.140
Now let's go ahead and put a small prompt right in here.

04:29.170 --> 04:33.610
So I'm going to say name and go ahead and save this refresh.

04:33.640 --> 04:34.570
And you can see name.

04:34.570 --> 04:37.030
So we call this know what the form is doing.

04:37.030 --> 04:44.500
So go ahead and say um this is uh George Steve and click on submit I have George Steve printed out.

04:45.010 --> 04:50.020
So if you want to input something like a name let's go ahead and say what are the name.

04:50.050 --> 04:51.970
Go ahead and put a break tag right in here.

04:51.970 --> 04:58.360
And I create a new c h I'm going to say what to add H.

04:58.390 --> 04:59.260
You understand.

04:59.260 --> 05:01.510
So go ahead and say input.

05:01.510 --> 05:05.620
And the type is going to be numbers.

05:06.070 --> 05:06.670
You understand.

05:06.700 --> 05:11.520
It's is known to be a text because we are dealing with numbers right now, so we'll go ahead and give

05:11.520 --> 05:12.360
it a name.

05:12.390 --> 05:18.570
Always give a name and whatever your inputs here, name, whatever you insert inside that name is what

05:18.570 --> 05:19.170
it's going to give.

05:19.380 --> 05:19.680
PHP.

05:19.710 --> 05:26.040
So if I put H or anything inside there, I'm going to let PHP know that this is what I'm working on.

05:26.070 --> 05:26.790
You understand.

05:26.790 --> 05:36.930
So go ahead and close that and I'll go right inside PHP and say echo and uh dollar underscore get.

05:36.930 --> 05:39.900
And then you go ahead and put in H.

05:39.930 --> 05:43.050
Save this and let's refresh this and check it out.

05:43.050 --> 05:48.030
So it says we have a syntax error right in here.

05:48.030 --> 05:52.860
So what actually happens right here is that I just want to echo this out.

05:52.890 --> 05:54.990
Go ahead and copy this.

05:55.470 --> 05:59.460
So I want this to be another stove right in here.

05:59.490 --> 06:05.190
Then go ahead and say so save this right now refresh this page.

06:05.190 --> 06:09.050
And uh we have name we have age.

06:09.050 --> 06:19.880
So if I go ahead and say name is hello and age is 20 and click on submit, we have hello 20.

06:21.200 --> 06:22.010
So you can see that.

06:22.010 --> 06:23.780
So we have hello 20.

06:24.470 --> 06:29.420
So I have two PHP uh tags right in here.

06:29.450 --> 06:34.820
If first one is echoing the username the second one is echoing the age.

06:34.850 --> 06:37.520
As you can see, our form is actually working fine.

06:37.700 --> 06:40.940
So let me say I want the 20 to be below.

06:40.940 --> 06:46.640
Go right in here after this PHP five and see I create a break tag.

06:46.640 --> 06:49.190
And let's go ahead and refresh this.

06:49.190 --> 06:51.590
And you can see that 20 has gone below.

06:52.340 --> 06:56.270
Now you can go ahead and make these customized a little.

06:56.300 --> 07:04.280
Let me say I want this guy and see your name is okay.

07:04.310 --> 07:05.720
Your name is.

07:06.230 --> 07:12.430
And uh, the second one Your age is 70s.

07:12.430 --> 07:14.140
And let's refresh this and check it out.

07:14.140 --> 07:15.460
So your name is hello.

07:15.490 --> 07:16.720
Your age is 20.

07:16.720 --> 07:22.570
So your name is George and your age is 24.

07:22.570 --> 07:23.830
So I check it out.

07:23.860 --> 07:25.390
Your name is George.

07:25.390 --> 07:26.920
Your age is 24.

07:26.950 --> 07:28.600
You can be able to see that right in here.

07:29.170 --> 07:33.040
So this is a way of accepting input from a user is in PHP.

07:33.130 --> 07:40.810
And for every form you create in HTML, you can see that we can actually use PHP to get the inputs from

07:40.810 --> 07:41.290
the user.

07:41.290 --> 07:44.350
And you can now move those inputs to our database.

07:44.470 --> 07:46.750
Right now we are not talking about database.

07:46.750 --> 07:51.820
That is why the input is just displayed on the screen, because you don't need to put this input on

07:51.820 --> 07:52.390
your screen.

07:52.390 --> 07:57.610
So when we talk about database then we'll go ahead and learn how to take this input and move them to

07:57.640 --> 07:58.300
the database.

07:58.300 --> 07:59.830
So for now practice with this.

07:59.860 --> 08:00.490
Check it out.

08:00.490 --> 08:03.940
And if you have any question on this use the question and answer section.

08:03.940 --> 08:06.670
And I'm going to get back to you as soon as possible.

08:06.700 --> 08:07.690
Thank you so much.

08:07.690 --> 08:10.930
And I'm going to see you in the next video lecture.
