William Rosener: Hello, Dr. Bill, welcome back. This video, we learned how to create a health club calculator using PHP. Let's start by taking a look at what you learn how to create and then we'll
William Rosener: recreate this thing from scratch, all the way to the end there. Okay, so what's going to happen is we're going to have some radio buttons will have some checkboxes.
William Rosener: And initially, when we're finished here, we're going to have these so that when there is a change or automatically computing and new total them.
William Rosener: And the other thing which we're going to want to do is make sure that this thing is mobile responsive and that means that as I resize this you can see how that information is going to be stacked vertical and
William Rosener: Okay, let me show you what we're not going to do kind of a bad example here.
William Rosener: Okay. Here's the bad one. Let's assume it's platinum that's 100 and tennis is 15 let's sit to calculate total
William Rosener: And when I do it, sure enough, platinum was hundred to 1500 15 but notice I no longer have these options. Select I want to make sure that when I call this thing over and over that.
William Rosener: These options that were selected remain selected them. Okay, let's get started here for first thing you want to do is open up some basic editor Notepad Word Pad. There's a bunch of editors out there. Let me just grab a little code here.
William Rosener: And I'll paste. Okay, so let's take a look here. What did we just do. We're going to start an HTML.
William Rosener: We're going to close the HTML. We're going to start our head. We're going to close the Head Start the title. Close the title.
William Rosener: Start our body would have a little padding around the outside. So this stuff isn't really crammed right here against the border.
William Rosener: And start a header to tag, close the header to tag start our name close name put a paragraph break start a forum closed form. And what you're going to find is, as we call this form, it's going to keep calling itself.
William Rosener: Over and over, in effect on the server column itself. Let's go ahead and I say that I'm gonna come up here to File, Save As.
William Rosener: And let's just go ahead. I'm gonna save the second Aaron.
William Rosener: And you guys can have to do this from scratch them, but I'm going to go ahead and call this assignment.
William Rosener: For desk PHP and make sure it ends with the extension PHP. So three steps there File, Save As. Make sure you know where you're saving it.
William Rosener: Make sure you've got the extension or the file assignment for desk PHP dot PHP. Make sure it ends with that extension PHP and it's a text document when you get all three things done. Go ahead and press Save.
William Rosener: Okay, at this point, I'm going to go ahead and if I hit refresh up here.
William Rosener: I can now see it and I'm going to right click on it and I'm uploaded to the server. At this point, I can come back over here. Hit refresh. And here is the file. We now have just created there. Okay, well let's keep building and I'm going to do a little copy and paste in here.
William Rosener: And let's go ahead and we'll start off with our division tax.
William Rosener: Right there.
William Rosener: Let me just put some ones in here.
William Rosener: Okay, that was the first division. I'm not going to go ahead and grab a second one.
William Rosener: And put some tools here.
William Rosener: And I've got these colors here and probably when I'm finished. I should probably take them out. But I'm just going to go ahead and leave them there. So you can clearly see the various divisions here.
William Rosener: Okay, now I want to go ahead and insert this is going to be like a line feed, hard return. So I've got these first two, which are floating. I've got ones and twos. This one is going to break it. Some. Now I'm going to be the next information is going to start on its own line.
William Rosener: Grab a little code here paste. I'll put some threes here.
William Rosener: I'll close this division tag. And one last one.
William Rosener: Foot some fours and I'll close the division tag so far, I've got everything open and close. So I would have a couple here, all we're going to be floated to the left.
William Rosener: This is gonna be like MY HEART. RETURN. And then a few more. Let's go ahead and I say that I'm to come up here to File, Save. We come back to my browser or mean my FTP Zilla I'm going to upload this
William Rosener: Would take a look in my browser, and I'll hit refresh. And sure enough, we got the 123 and four. And if you wanted to.
William Rosener: You would see how that information will stack vertically
William Rosener: If the browser is small, or minimize them.
William Rosener: Okay, well, rather than putting a bunch of one twos and threes there. We're going to go ahead and actually put some values there. So the first one here is
William Rosener: Our radio buttons. So we got a little code here. So I'm gonna highlight all the ones here. I'm going to delete that and paste. And so what what am I paste in here.
William Rosener: I'm gonna start a definition list. Close the definition English turn the kind of the term being defined membership.
William Rosener: I'm gonna have some radio buttons. Notice all three have the same name membership. So the function as an array, and I've got some values outside
William Rosener: Okay, before we can really do anything else we need to also grab some information for the calculate total. So I'm gonna copy that I'm gonna come down here where the three, sir. I'm going to paste that. Again, the definition list and
William Rosener: Input type submit
William Rosener: Calculate total I'll let you guys figure out the clear and then we'll come on down here for the last one. So we actually have a spot to place this information.
William Rosener: I'm going to
William Rosener: delete these fours.
William Rosener: And I'm just looking right here, what's going to happen is I'm going to start another PHP script and all it's going to do is display whatever is in total.
William Rosener: Well, we don't have anything in total. So I'm going to go ahead and come up here to the top of those who would get a an error message on the server. Let me just grab a little code here.
William Rosener: Come up to the very top, and I like to place it at the very top. And the reason I do this as I'm working with images.
William Rosener: And I'm not sure if we'll be doing too much with images in this class. But if there's even so much as a single space or blank line.
William Rosener: Then it wants to go ahead, a lot of browsers. Oh, what's about to be received is HTML content. And it's like, well, now I'm trying to
William Rosener: Have the user download an image, and it doesn't work. So a lot of times I'll just start at the very top. So if I'm going to be working with images.
William Rosener: I've got something there. Okay, so appear. These are like my default values or if there was no or my initial state. So the very first time I call this
William Rosener: They have some values there. So, these, this is a variable for tax for total the dollar sign says about it's a variable membership tennis racquet ball and golf. Let's say that list, we won't get an error message now.
William Rosener: And I'm hit upload
William Rosener: And you would actually see that error message right over here. If you were to create an air and let's come along and hit the refresh or the reload, but now
William Rosener: I tell you, I maybe I should introduce an air.
William Rosener: Okay, let's, I'm going to put an extra t here and tell it all. I'm gonna come up here to File, Save. I'm going to come along and hit the reload button.
William Rosener: And let me just to calculate total just to make sure enough I come back here to my FTP and hit
William Rosener: Refresh, sure enough, there is an air and I'm going to go ahead and delete that air.
William Rosener: And what did I get that air because down here. It's looking to display something in total. Well, I don't have a variable called total because I got one with two T's and now i'm not i'm set there. So let's go ahead and hit save. I'm gonna go ahead and upload this
William Rosener: And refresh.
William Rosener: And or resend them. Okay. And again, sometimes what I'll do is this, come right back here and there we go. Okay, but now I need to start working with some code here so that when we press on this a total is actually displayed there.
William Rosener: And the very first step. I'm gonna do is
William Rosener: Just copy and paste some code here. And you'd already have that maybe from another assignment. It's just going to test them put making sure no one has entered any malicious data trim and removing white spaces.
William Rosener: Making sure special characters etc are removed there. OK, now I'm going to go ahead and
William Rosener: Start if the information if there was a post and I'm going to close. So what's going to happen is we're going to when I press the button, it's going to post this information to itself. Okay. And let me go ahead and grab a little code here.
William Rosener: copy it and paste
William Rosener: And make sure you got this. So I'm gonna start my post
William Rosener: And make sure you've got this close. So now what's going to happen is I'm going to take a look. Has anything been posted a membership. This is my initial state.
William Rosener: Now when I recall call it again I press on the calculator total button. What's it going to do, it's going to call itself.
William Rosener: And I'm going to take a look okay has some information been posted in membership. Then I'm going to take a look. Okay. If it's basic at platinum hundred
William Rosener: And gold. Gold would be hundred 20 so so go ahead and actually check that. I think we've got something that should begin to work here. File, Save.
William Rosener: Upload it
William Rosener: And let's hit the reload button or let me come back here, press on it again. And now I'm gonna choose a platinum.
William Rosener: And sure enough, it's 100 gold hundred 20 and let me just check basic at, okay, again, we're going to be working with this to make sure that these options. Stay there, but let's go ahead and start working over here with these tools.
William Rosener: Okay and I'm gonna come down here with all the twos and that's where we're going to put our
William Rosener: additional charges.
William Rosener: So I'm going to copy that when I come right over here.
William Rosener: And paste and if you wanted to. I'm going to be adding some information as I am.
William Rosener: Okay, so here is my additional charges. I got stuff for a tennis racket ball and golf. Let me go ahead and save this.
William Rosener: Upload it it's not working yet. And I'll hit the refresh button.
William Rosener: Ok ok now we need to start working on this so that when these are checked will add up additional values there.
William Rosener: Okay, someone to come up here to the top in my code.
William Rosener: I'll tell you what, I'm not. Well, not only that tax for later. I'm going to copy little code.
William Rosener: Come down, down here. Make sure you can see this little curly bracket that's closing this on within here. I'm going to paste
William Rosener: And here's the information I've just added. I'm going to take a look as tennis as that then selected post is it set up so I'm going to take. So these initial ones up here.
William Rosener: Took at and assigned to the total now I'm gonna do is I'm gonna take one's ever in total at 15 take one seven total at 20 except for them. Okay. I think this part should be now working here. Let's save that. Let's upload this
William Rosener: Take a look.
William Rosener: Come back here and maybe even played safe. I'm hits a controller fog and make sure everything is working. So here's platinum. Here's tennis. I'd love to see 115 right there. And sure enough, here's platinum. Here's racquetball I'd love to see 120
William Rosener: And. Great. Okay. I think it's hopefully working here. Now what we want to do is make sure that when we select these whichever ones we select maybe all of them. They remained selected, even after I press calculate total them.
William Rosener: Okay, well, how we're going to do that. Let's come back here to the code. I'm going to come on down here.
William Rosener: And I'll tell you what we should probably be at well we got to get around to tax or sometime
William Rosener: We grab a little carrot here. And so I need to place this within. Here's the starting bracket. Here's the closing someplace in here, I'm just going to place it right here.
William Rosener: And if you want to put it right there. I'm going to take a look as membership set hips and then I'm going to take a look. Is it set to basic if so I want to make sure that this one is checked.
William Rosener: And then I'm just gonna repeat this
William Rosener: Process platinum I'm does exact same thing. Put a hard return here.
William Rosener: I'm going to paste it and then maybe I'll tab. This over and close. So now I'm gonna take a look, his membership set and is it set to platinum make this one checked.
William Rosener: Okay, then we'll do the same thing with goal.
William Rosener: Okay. And at this point. Is it sad is it set to gold. Make it check. So now when I call my when I call this thing a second time. I'm going to take a look as basic
William Rosener: Hat. Was it checked if so make sure that it remains check them. Okay, we could check this out. Okay, well, we'll go ahead and do that on the file save will come back to my FTP upload it.
William Rosener: Come to my health club calculator about come back here to the beginning, press on it.
William Rosener: If you wanted control five to make sure that you're looking at a fresh version. I'm going to choose platinum and tennis and it hits a calculate total
William Rosener: Sure enough, I'm getting 215 but notice now my platinum is still saying check now we're seeing to repeat this over here for the additional charges.
William Rosener: Okay. Same thing here. Maybe I'll place it right here. And we need to place this within the angle bracket close bracket. I'm gonna paste
William Rosener: And maybe I'll just like I did earlier kind of break that up. So now I'm going to take a look as tennis set and it's set to yes I'm gonna make it checked.
William Rosener: And I'll do the same thing with racquetball
William Rosener: Okay. Is racquetball said, so is it set to, yes. Make it checked and then finally we get to the same thing with golf.
William Rosener: Okay, so if you're not kind of paying attention here. What am I doing here is I'm actually starting another little bitty script. This is an angle bracket question mark PHP is starting to PHP script here on closing it
William Rosener: And I'm going to be taking a look at some values and depend on those values. I'm going to display checked or not, or it's going to be remain blank there. Okay, let's go ahead and save this.
William Rosener: Take a look at upload it.
William Rosener: I'm gonna come back here, refresh, maybe hit that control F5, make sure I'm looking at it fresh version on the choose platinum and tell us
William Rosener: Sure enough,
William Rosener: But the big thing is, notice that they're stupid. This one racquetball as well. Notice that these values are remaining checked.
William Rosener: Even someone I hit the calculate total look up here and you're going to see, see how it called the server and the server is actually in Arizona, it's calling it really quickly.
William Rosener: And effect producing the output and then re displaying all the information again there. Okay, one last thing we're going to be doing. Actually, we're going to get that tax in there as well.
William Rosener: And then we're going to have it so you don't have to press that button over and over. Okay, let's say I get the tax.
William Rosener: And so someplace up here. I can place this anywhere here.
William Rosener: I'm going to take a look okay was some information. You can see initially. I'm just going to have set it to zero. But now when I call this thing again. I'm going to take a look okay whatever information was in tax stored in my variable that I'm going to come down here to the bottom.
William Rosener: And I'm going to paste and what's going to happen is we're going to in effect. Take our total times attacks plus total. And then this is going to round it to to decimals. So we can go ahead and save
William Rosener: And we can upload
William Rosener: It. And at this point, we could choose platinum.
William Rosener: And I could put in 10%
William Rosener: And hit calculate total
William Rosener: And notice, it is calculated the correct amount, but what did it do we need to do the exact same thing with tax so I need to come on down here.
William Rosener: Grab a little code.
William Rosener: Okay. And right here.
William Rosener: I need to display.
William Rosener: So when I call it again. It's going to display. What is intact so hopefully this is begin to start to make sense. It's going to come up here. It's going to call itself.
William Rosener: And then it's gonna become an appearance going to go, oh, what information was posted well taxes posted. So I'm gonna take that information and stored in the variable.
William Rosener: And then write down here, all this doing I'm gonna start a little script close a little script and it's going to display or echo whatever information is in tax since I go ahead and save this.
William Rosener: Upload it
William Rosener: Come back here and make sure maybe mid to control F five
William Rosener: hits a platinum. I'm gonna go with point 110 percent I'm hit to calculate total. And sure enough, the radio button to stand selected and so is my tax remaining
William Rosener: From the previous time I had called it. Okay. The only last step I'm going to do is now make it so that when these change or the additional charges or even the tax it automatically calls itself, so I don't have to keep pressing the calculate total command button there.
William Rosener: Okay, let's, uh, come right up here. We're going to start with the memberships.
William Rosener: And all I do is just paste this information numerous times coming from right out here. Whoops. Let me get my cursor here. So, here what come up here, first to that radio buttons.
William Rosener: Here's the membership. I'm just going to paste on change called reload form. Same thing here. We load form in three load form. Okay. Let's also do it for
William Rosener: these check boxes. So if it changes reload the form reload the form reload the form and Ross going to do it with attacks just someplace in here. Maybe I'll place right here.
William Rosener: So on change this changes reload the form. Okay, one. Now, it's not going to quite work yet because we don't, we're calling a function called reload form and we need to get that displayed here.
William Rosener: So we're here, down at the bottom. I'm just going to start a script. This will be a JavaScript. And what's going to happen is anytime I call reload form, it's going to get element by ID. And notice, I called mine. Make sure you match health club form.
William Rosener: Okay, health club form, it's going to call it an effect resubmit it. So let's go ahead and take a look at this. I'm going to File, Save.
William Rosener: I'm gonna upload
William Rosener: I'm going to come back here.
William Rosener: Maybe even make sure I hit refresh. I'm looking at a current one. So there's platinum tennis and I can see the values are changing every time I call it, but also take a look up here.
William Rosener: And what's happening is, every time I change one of these. It's gone. Arizona and back because that's where my GoDaddy account is in effect.
William Rosener: Calm is form again and again and again and again again now and probably let you work with the clear button. I may even have you add some additional charges over here just to make sure you're kind of
William Rosener: Paying attention and following the code here. But one thing to keep in mind is take a look here. Every now and then maybe even come up here to view refresh.
William Rosener: If you are getting an error message over here, take a look at it opened up in a browser, maybe you'll get some pretty helpful information there.
William Rosener: And tell you what line you're on. And probably the next next video action will purposely
William Rosener: Use an editor that has line numbers, maybe notepad plus plus there. So if I'm getting an error message on line 30 I don't have to go 12345 I can just quickly look to see what line 30 is
William Rosener: And it would probably tell you, you know, it's like okay there's something wrong with the line and just take a look at that. If you're having any trouble serum.
William Rosener: So just kind of take a look here, the big picture there here at the very top. These are my default values or when I first call it water, the value is going to be set. This is simply doing some
William Rosener: Making sure no malicious data has been entered. Every time I call this function. This PHP over and over. I'm going to be posting information.
William Rosener: To this PHP script and I'll be taking a look at information posted and working with it. Well, hopefully this video, we learned how to create a simple little health club calculator using PHP. I'll catch the next video. Thank you. Bye.