 What's up team welcome back. It's your biggest fan of the real cast of Darrow and I want to congratulate you for making it to part 3 This is where we start to see code. This is what we're building is a very simple PHP Application that is going to act as a script to handle any rebel crust We send to our our mock server that we've built your team and then after that from that point on right? You'll have the basic fundamental knowledge to to construct a very simple application And in the in the future lessons to come we're going to get into CSS and then we'll get in a JavaScript and as we progress My my hope the goal is to give you this foundational knowledge that you can use to go out and build Anything you want. That's what this is all about team is making it possible. So people who have never The crew could never wrap their head around this technology or people who just feel like they aren't smart enough or Or they they just need maybe they don't have the the opportunities or whatever is so Anybody can go out and build anything team so that's why I started with the forms because the forms are a very important part of of any Application because you have to have input but from here on out, right? We're going to go This is the foundational knowledge. You've got it now team and from here We're going to build on top of that now when we cover PHP We're not going to get into all the different programming You know all the syntax and in the different things that are involved in program in a programming language but hopefully it'll give you a baseline understanding of of how Applications work team and then we'll build on top of that baseline Understanding it will teach you about types and variables and functions and all this other stuff that you hear about out here That maybe it's confusing you team. So anyway, that's enough of me talking. This is all about you team I want you to be able to build stuff. So here let's get right into it All right team So what we're going to do is we're going to close out our original VS code file So do control w and another control w and we are going to hit the windows key and we're going to well actually we'll hit windows e to open up explore and we're going to go to our route directory our route are our C drive we're going to our exam folder and we're going to go into our ht docs folder ht Docs and now we're in here and what we'll do is we'll right-click and we'll say Open with code and it's going to open this folder with visual studio code We can close this we don't need that anymore and now we here we have our index that HTML now if we look up here I have post in here again. So let me delete this so we can start from scratch team So I'm just going to save as that and this action is What's going to happen when we hit the submit button? So what we're going to do is we're going to call a php file and we're going to make that php file So right now we're just going to put in the dash and we're going to say php and then we're going to do another dash We're going to call this What do we call it we'll call it action? underscore php dot well action underscore page dot php safe now this file doesn't exist So we're going to make it right in this folder doesn't exist either So so we're going to go we're going to right-click here in our Explorer inside of visual studio code with a new folder we're going to name this folder php and Inside of that folder. We're going to make another file. So we'll right-click on that folder. We're going to say new file And we're going to call this action underscore page dot php So now we have our action underscore p dot php and we're just going to make a simple php file so we will do a Control no not a control a shift asterisk and hit tab and we got our basic HTML document And we're just going to name this action page. So we'll go over here and we'll say action Page and in our body is where we can put our php code team So down here in our body what we're going to do is we're going to put a we're going to put our asterisk right there Inside of our body and we are going to type for both not form action So we're going to take our we're going to take what we have on our form And we're just going to put it right here team So we're going to say hey when we call this page. We want to return a username username So we could say well we can just say user is That and then we're going to put some php code in here So I know you don't understand what's going on But you will understand what's going on at some point all right So we're going to say hey We're using the php programming language and we're going to say we want you to echo back Whatever we get and in this case we're going to send a post request from our form. So we're going to make this capital And what's going on here team is what happens is php runs on the web server and the web server has Variables and this post is what's called a global variable It is accessible anywhere from inside of a php application from every function or everything and I know some of you don't understand What I'm talking about right now and that's cool team because it's going to make sense the further you go Along all right, so we're going to put this echo post and then what we're going to echo back is we're going to say We're going to say name So what we're doing is we're reaching into this variable and we're grabbing one of the elements inside of this variable So when we send our form using the post request we send all of this information So we send a name we send a password right and we've got it all outlined here Right we send the password and then we we're going to send a gender So that this is all the information that's going to be sent. So you see what I'm saying when we We put all this in a form and we have our submit button inside the form and because it's inside of the form It says hey, I'm gonna do whatever action is attached to this form and right now. We've got this action We got this deal up here. Hey, we're gonna contact this page and then we're just gonna go over here We're gonna say when we contact this page, we are going to use the method of post P and we'll make that capital Save and now we've got this post method right there And so when we go back over here, what we're gonna have it do is we're gonna have it tell us back what we sent So in here, we're just gonna put name and then underneath that we're going to put Password and then underneath that we're gonna put Gender and then we'll separate all of these with some BRs And what's gonna happen is when this is processed So when we send this to the server the PHP the Apache server Runs this script through a PHP parser and the PHP parser Says hey, right when the server gets our request It takes this information that we have here our username and actually so we'll copy this this username We'll paste it here It's going to take this username and it's going to put it in this variable post as a username and Attached to this username is going to be whatever value that we submitted with our form in our input field if that makes sense team We'll go back here. We'll double check we've got user password So we'll copy that we'll go back over here We'll paste in our password and then last but not least we've got our gender down here So if we go down here and we look at our gender remember this is radio button So we enter one gender, but when we submit our form Whatever the user has checked best was going to be sent to the server And when this stuff is sent to the server the server just puts it in the memory and it just sits there now This is a security issue But we're not we're not at that level yet because what we could do is we could enter Database requests all kinds of stuff into this form and PHP would just return us Whatever we put like if we gave it some sort of command it would do whatever that command was And so that's where we get into the realm of security and in form validation and all these things team So let's go back and double check and make sure we have our gender right alright We do and so what's going to happen is when we send our form The the data that we send which is going to be our username our user password and our gender is going to be loaded into memory inside of the pulse variable Under username user password and gender along with that information that we sent is users when we entered our information in the form and Then the server is going to run This page through the parser because we're calling this page and when PHP is parsing it is going to say hey post Give me username. I want to echo that back. I want to I want to send this back to The user that requested it and there's going to do the same thing for password It's going to do the same thing for gender. This is going to be processed into regular html And we're going to be sent back a web page with the information that we sent to the server So we'll hit save and if we go over here and we type test Test and we set this to man and submit up something's wrong team So we got to go back over here and double check and see what we got going on my bad team So what we got to do is we got to put a semi we got to put semi colons after all of these So we'll just click here and we'll hold down the alt key and we'll click here in here We'll add some semi colons just like that team and then we're going to put a question mark and a Greater than symbol and this is going to close out all of our PHP statements So we'll hit save with the control s will go here to our local host will refresh that page I'm going to say retry so now we're on a local host again And we're just going to enter test and we'll submit and it tells us user test user test and user other We need to change these so we're going to go user and we'll go pass word and then down here We're going to put gender. All right team. So we'll save that and we'll enter some different information this time So we'll refresh our form retry and let's go back here to our main page We'll refresh this page retry and what we'll do is we'll say hey team I'm TRC and my password is going to be I'm not going to tell you but you'll see it in a minute I think hold on. Let me do this again. All right. I'm just going to make it super simple Well, I don't want to make it like that. We'll just do this All right team and then I'm a guy So I'm a just put man and we'll hit submit and it's going to say user is TRC The password is password and the gender is man team So now we we have an actual application that will return us some kind of data when we send it Over to the server now. Let's say for instance the server. Let's say we send it Not that right there, but we go let's save this and then we go back into our index.html And let's say this wasn't user password. It was just password or something like that password save and then when we go back to our local host So we'll go back to our main page and we'll refresh that And then when we go test we go past the word we should get some sort of an error P.A.S.S.W.R.D. Then we'll set that for man and we'll go submit And see we get an error user test password notice undefined index user password and cx that PHP online 12 gender man now here's the deal right what we would do in real life is we wouldn't want to return anything if if something was sent to the server that the server didn't understand we wouldn't return any data we just say hey look something's wrong but we haven't set that up so it tells us exactly what the problem is the last thing we want is someone to be able to come onto a website and enter a bogus username and a bogus password and have the application tell whoever entered that information hey team undefined index user password because now they know that the application that's being called when they submit that form is expecting user password right it's expecting this this the value that we submit to be submitted as user password and that opens up the gates to all kinds of crazy hackerish stuff team so what we're going to do is we're going to go back here we're going to change this back with the control z a few times safe and if we go back to our page again and we refresh we try there we go and we're just going to go trc and we're going to set our password and we'll be a man and we'll submit and now it does the same thing that we wanted it to do before so now that we got our basic php application setup we can go back and we can keep continuing digging into these input elements in our html form team but before we do that i just want to recap real quick right so php is a programming language like any other programming language like javascript or like whatever and what we're seeing here is when we send our information to the server like i said it goes into this post this post variable and it's it's it goes in as a as a key value pair or an array i'm not i'm not really sure but so what we see is we can call username and it's going to return whatever value was sent with username right and normally we wouldn't do that we'd have we'd we'd we'd submit something in post and then the application that runs would check the database does the username exist yeah all right does the password exist yeah okay all right so now what we can do is we'll return this information back that's well that's well what happened with the typical long gone scenario if the username doesn't exist then it will return some sort of different response maybe it would say hey your username's incorrect or you don't exist or whatever right but the reason why i'm going over this is because when we build stuff we have to think about things like this like what is going to happen if somebody does something wrong they enter the wrong information or whatever and while we're while we're thinking about this stuff we have to think about how to put things together and this helps us understand all of this stuff at a fundamental level team and when we understand it at a fundamental level we can go out and we can build our own stuff we don't have to worry about anybody else we can find the answers we need and we don't need a bunch of additional technology and most importantly if we do need additional technology we know right we know when we want to use a node or we know when we want to use an angular or we know we want to use you know some sort of plugin or library or whatever right because at that point we're just looking for other pieces of code to help us accomplish something that we're trying to accomplish we're looking for other pieces of code to help us solve the problem but now we know what type of code we need to look for right and we know we know what to search for and what to study so if we're building a log on form right we search for it how do i make a log on form that is safe and secure how would i call the server with this form and all these different things team so that is it for this video right here in the very next video we're going to come back and we're going to dive further into we're going to dive further into the the input elements all right team i'll see you in the next video