WEBVTT

00:00.890 --> 00:05.810
In this lecture, I'll go ahead and teach you how to make some calculations from the user input.

00:12.470 --> 00:12.830
All right.

00:12.860 --> 00:18.440
So in a previous lecture we were able to create a form and were able to input a user name and age.

00:18.440 --> 00:20.450
And you can see how to collect those forms.

00:20.480 --> 00:23.570
Now let's go ahead and create another form right in here.

00:23.720 --> 00:28.940
So I'll go ahead and say form and I'll go ahead and close this form.

00:29.420 --> 00:30.260
All right.

00:31.340 --> 00:34.040
So let's go ahead and close the form.

00:34.040 --> 00:38.840
And now we just go ahead and do exactly just what we did given an action.

00:38.840 --> 00:41.810
And that is site dot PHP.

00:41.960 --> 00:49.160
And that method just be the same again add a get method because we want to get some input from a user.

00:49.190 --> 00:55.670
I will do some calculations to see how it works in order to help us to understand how PHP works.

00:55.670 --> 00:59.600
Now I will go ahead and give you a prompt because you have talked about prompt.

00:59.630 --> 01:01.010
Let me say this is number one.

01:01.010 --> 01:07.040
And then we go ahead and let me go ahead and put two so that we can be able to say let me say Missy,

01:07.070 --> 01:09.080
Num1 and Num2.

01:09.110 --> 01:15.350
So we go ahead and give some input to this.

01:15.350 --> 01:18.740
So for Num1, I'm going to create an input tag for Num2.

01:18.770 --> 01:20.780
I'm going to print an input tag.

01:20.780 --> 01:24.050
So now I'll go ahead and say you can create many.

01:24.050 --> 01:27.950
Maybe you want to collect two or 3 or 5 uh inputs.

01:27.950 --> 01:28.910
That is no problem.

01:28.940 --> 01:29.420
All right.

01:29.420 --> 01:35.000
So this is just to help us to play around with PHP and the type is number.

01:35.000 --> 01:39.170
And because, oh, I click on this let me say a number.

01:39.170 --> 01:46.730
And let's go ahead and give it a name and let the name be my known Ricky.

01:46.760 --> 01:48.440
Let me say this is my number one.

01:48.470 --> 01:48.980
All right.

01:49.010 --> 01:50.180
Go ahead and close this.

01:50.180 --> 01:58.700
And then for the second one I'll go ahead and say inputs and let it type of inputs be equal to number

01:58.730 --> 01:59.480
again.

01:59.480 --> 02:06.140
And the lady name be equal to my number two.

02:06.320 --> 02:07.940
And go ahead and close this.

02:07.940 --> 02:13.490
So we have been able to create inputs form for Num1 and Num2.

02:13.490 --> 02:13.490
two.

02:13.520 --> 02:17.240
So what remains right now is to go ahead and create a submit button.

02:17.240 --> 02:25.880
So the input stack for this let's go ahead and set type is going to be submit.

02:25.910 --> 02:27.200
Go ahead and close this.

02:27.200 --> 02:31.130
And if we refresh this we have Num1 and Num2.

02:31.160 --> 02:34.400
So I'm inputting text and I'm clicking on my keyboard.

02:34.400 --> 02:37.580
And then nothing is being done because it's just a number.

02:37.580 --> 02:43.880
But if I go ahead and put numbers 123456, seven, eight, nine and the computer set only inputs, let

02:43.880 --> 02:45.770
me say I have a two.

02:45.770 --> 02:47.750
And down here I have four.

02:47.750 --> 02:50.660
And if I submit these I have nothing have been done.

02:50.660 --> 02:56.270
So I need to go over to my PHP right in here and be able to execute this.

02:56.270 --> 03:03.710
So let me go ahead and say for the first one I'll go ahead and give it a create a variable called my,

03:04.490 --> 03:06.260
let me say my number one.

03:06.260 --> 03:12.680
And now go ahead and create another variable down here and I'll call that my number two.

03:12.830 --> 03:13.310
All right.

03:13.310 --> 03:20.320
So for number one I'll go ahead and say this is equal to dollar underscore gates.

03:20.320 --> 03:24.400
So give me anything that is inside the form number one.

03:24.430 --> 03:25.000
All right.

03:25.000 --> 03:28.930
So I'm going to get whatever it is inside here.

03:28.930 --> 03:30.100
So I'm going to copy this.

03:30.100 --> 03:33.130
And I'll go ahead and paste that right in here.

03:33.160 --> 03:33.850
All right.

03:33.850 --> 03:38.230
So and this is equal to the second one which is number two.

03:38.410 --> 03:42.670
Go ahead and move this a little bit so it can be awkward can look clean.

03:42.670 --> 03:48.850
And then go ahead and copy what is right in here and put in there.

03:48.880 --> 03:49.420
All right.

03:49.420 --> 03:56.860
So this is just a variable name I can say that this is my or number one or number two.

03:58.270 --> 04:02.320
So let me see I don't want this name to just be the same thing here.

04:02.350 --> 04:04.690
So can we want to know what we are doing.

04:04.690 --> 04:07.300
So let me say this is a number one.

04:07.330 --> 04:08.170
All right.

04:08.170 --> 04:11.260
And this is a number two.

04:11.290 --> 04:17.080
The reason why I'm differentiating this is that you don't think that the name must be the same.

04:17.080 --> 04:20.170
No, no, this is just a variable name okay.

04:20.200 --> 04:24.400
Now our goal right here and equal out whatever we have.

04:24.400 --> 04:27.490
So equal Outs.

04:27.790 --> 04:29.020
These.

04:31.030 --> 04:31.570
Echo outs.

04:31.600 --> 04:34.840
I'm going to make this to be in a lower case.

04:34.840 --> 04:37.450
So it's always really good as a variable.

04:37.450 --> 04:40.180
So this is a nice one.

04:40.180 --> 04:41.920
We can actually make that to be upper case.

04:41.950 --> 04:42.760
There's no problem.

04:42.760 --> 04:44.740
I just want my code to look good.

04:44.740 --> 04:50.380
So number one plus.

04:52.540 --> 04:54.280
Number two.

04:54.400 --> 04:54.910
All right.

04:54.910 --> 04:57.880
So I just cut out this I will go ahead and save this.

04:57.910 --> 04:59.710
Let's go ahead and refresh this and check it out.

04:59.710 --> 05:07.510
And it says number two under unexpected variable number two in this and line 15.

05:07.510 --> 05:12.670
So what actually happens here is we didn't put a semicolon at the end of all this.

05:12.670 --> 05:14.650
So we had a semicolon at the end of this.

05:14.680 --> 05:15.730
And save this again.

05:15.760 --> 05:16.930
Go ahead and refresh this.

05:16.930 --> 05:19.120
And now we have this.

05:19.120 --> 05:21.100
So I'll go ahead on that.

05:21.130 --> 05:25.720
Clean out all this guy and say three and two submit.

05:25.720 --> 05:27.670
We have five down here.

05:28.090 --> 05:28.630
All right.

05:28.660 --> 05:34.300
Now anything we input the NMC seven plus it will go ahead and submit.

05:34.330 --> 05:35.350
We have kicked in.

05:35.350 --> 05:42.460
So go ahead and change this to like a minus inside here and always save your code.

05:42.490 --> 05:48.250
Go back here and save four and two okay four and three so it can be significant.

05:48.280 --> 05:49.660
Go ahead and hit.

05:49.780 --> 05:52.030
That is equal to one.

05:52.840 --> 06:01.360
So our if we say ten minus seven and submit that is three, it can actually go ahead and make a modification

06:01.360 --> 06:07.180
and go ahead and say this to be two multiply eight.

06:07.180 --> 06:09.430
And this is equal to 16.

06:09.580 --> 06:12.970
So in that way you can allow users to input numbers.

06:12.970 --> 06:20.680
And you go ahead and uh from the back end you execute the program maybe multiplication, division,

06:20.920 --> 06:24.730
uh, I mean minus plus and so on.

06:24.730 --> 06:27.220
So I hope you can be able to play around with this.

06:27.220 --> 06:32.320
And, uh, in case you have have any question on this, please use the question and answer section.

06:32.320 --> 06:35.230
And I'm going to get back to you as soon as possible.

06:35.260 --> 06:36.280
Thank you so much.

06:36.280 --> 06:39.640
And I'm going to see you in the next video lecture.
