In this lecture, I'll go ahead and teach you how to make some calculations from the user input.
All right.
So in a previous lecture we were able to create a form and were able to input a user name and age.
And you can see how to collect those forms.
Now let's go ahead and create another form right in here.
So I'll go ahead and say form and I'll go ahead and close this form.
All right.
So let's go ahead and close the form.
And now we just go ahead and do exactly just what we did given an action.
And that is site dot PHP.
And that method just be the same again add a get method because we want to get some input from a user.
I will do some calculations to see how it works in order to help us to understand how PHP works.
Now I will go ahead and give you a prompt because you have talked about prompt.
Let me say this is number one.
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,
Num1 and Num2.
So we go ahead and give some input to this.
So for Num1, I'm going to create an input tag for Num2.
I'm going to print an input tag.
So now I'll go ahead and say you can create many.
Maybe you want to collect two or 3 or 5 uh inputs.
That is no problem.
All right.
So this is just to help us to play around with PHP and the type is number.
And because, oh, I click on this let me say a number.
And let's go ahead and give it a name and let the name be my known Ricky.
Let me say this is my number one.
All right.
Go ahead and close this.
And then for the second one I'll go ahead and say inputs and let it type of inputs be equal to number
again.
And the lady name be equal to my number two.
And go ahead and close this.
So we have been able to create inputs form for Num1 and Num2.
two.
So what remains right now is to go ahead and create a submit button.
So the input stack for this let's go ahead and set type is going to be submit.
Go ahead and close this.
And if we refresh this we have Num1 and Num2.
So I'm inputting text and I'm clicking on my keyboard.
And then nothing is being done because it's just a number.
But if I go ahead and put numbers 123456, seven, eight, nine and the computer set only inputs, let
me say I have a two.
And down here I have four.
And if I submit these I have nothing have been done.
So I need to go over to my PHP right in here and be able to execute this.
So let me go ahead and say for the first one I'll go ahead and give it a create a variable called my,
let me say my number one.
And now go ahead and create another variable down here and I'll call that my number two.
All right.
So for number one I'll go ahead and say this is equal to dollar underscore gates.
So give me anything that is inside the form number one.
All right.
So I'm going to get whatever it is inside here.
So I'm going to copy this.
And I'll go ahead and paste that right in here.
All right.
So and this is equal to the second one which is number two.
Go ahead and move this a little bit so it can be awkward can look clean.
And then go ahead and copy what is right in here and put in there.
All right.
So this is just a variable name I can say that this is my or number one or number two.
So let me see I don't want this name to just be the same thing here.
So can we want to know what we are doing.
So let me say this is a number one.
All right.
And this is a number two.
The reason why I'm differentiating this is that you don't think that the name must be the same.
No, no, this is just a variable name okay.
Now our goal right here and equal out whatever we have.
So equal Outs.
These.
Echo outs.
I'm going to make this to be in a lower case.
So it's always really good as a variable.
So this is a nice one.
We can actually make that to be upper case.
There's no problem.
I just want my code to look good.
So number one plus.
Number two.
All right.
So I just cut out this I will go ahead and save this.
Let's go ahead and refresh this and check it out.
And it says number two under unexpected variable number two in this and line 15.
So what actually happens here is we didn't put a semicolon at the end of all this.
So we had a semicolon at the end of this.
And save this again.
Go ahead and refresh this.
And now we have this.
So I'll go ahead on that.
Clean out all this guy and say three and two submit.
We have five down here.
All right.
Now anything we input the NMC seven plus it will go ahead and submit.
We have kicked in.
So go ahead and change this to like a minus inside here and always save your code.
Go back here and save four and two okay four and three so it can be significant.
Go ahead and hit.
That is equal to one.
So our if we say ten minus seven and submit that is three, it can actually go ahead and make a modification
and go ahead and say this to be two multiply eight.
And this is equal to 16.
So in that way you can allow users to input numbers.
And you go ahead and uh from the back end you execute the program maybe multiplication, division,
uh, I mean minus plus and so on.
So I hope you can be able to play around with this.
And, uh, in case you have have any question on this, please use the question and answer section.
And I'm going to get back to you as soon as possible.
Thank you so much.
And I'm going to see you in the next video lecture.