Bill Rosener: Well, this is Dr. Bill. Welcome back in this video you learn how to create a health club application using Php, this is going to be identical to the previous one. But last one was using Javascript, and this will be used in Php. And executing on the server. Let's briefly run through this really quickly here. So if I've got gold, that's going to be a hundred dollars if I choose, basic, calculate that that would be 80 platinum, 120,
Bill Rosener: and then these are mutually exclusive. We can only have one of these, but then, over here, on additional charges, we can have 0
Bill Rosener: 2 or all 3 of them select there, and if I have tennis that'd be $115.
Bill Rosener: And let's just go ahead and take a look at the assignment. 4 description. Here, I am going to give you all the code for kind of this. Actually, I'll let you work on the tax, and then the additional charges. So, having given you tennis, rackball and golf, I think you guys should be able to see if we figure out how to add these 3 additional charges there.
Bill Rosener: If you press right here on view a screen capture, this is going to be an image.
Bill Rosener: and like on the last one there you can go ahead and use the control and zoom in. Zoom out so you can see however much code you want, and again, take this image and use it as a reference there and then you can kind of use it to help you
Bill Rosener: enter this code there
Bill Rosener: again, since it's an image hopefully, don't. Don't spend any time trying to figure out how to convert an image into text. I'd rather see you guys tap this text. I think by retyping it. You're actually going to learn quite a bit.
Bill Rosener: Okay. So let's go ahead. And I get started. Here's what we'll be recreating here. So the very 1st step I'm gonna do is you open up a visual studio code? And I tell you what, before I do that I can, if I take a look over here. Here was one we just got done looking at. I'm going to be saving it on a temp folder on the desktop
Bill Rosener: assignment 4. And if I come over here.
Bill Rosener: Here is my desktop temp. I've got one file and same thing over there on the server.
Bill Rosener: So 1st step I'm do is open up a visual studio code, and I'm just going to go ahead and just to save a lot of time, I'm hit to control a copy. All this control C,
Bill Rosener: and right over here we go to file new text file.
Bill Rosener: And I'm just going to do paste. And I always like to have my Php code on the line one.
Bill Rosener: Let's just go ahead and start this. We'll take a look at it. So this is going to start my Php code angle bracket question. Mark php, when I come on down here, this is going to close it.
Bill Rosener: I'm now going to go ahead, and if it's got a variable, a dollar sign in front of it. These are variables. So I'm going to set tax initially to 0 total to 100 membership to gold. All these other ones. This here function is going to be testing whether or not malicious data has been inputted.
Bill Rosener: So then I'm going to be taking tax. I'm going to test it, test the input, test the input on tax, strip any unusual characters out and return it.
Bill Rosener: Then I'm going to take a look again. Those are going to be mutually exclusive. So one of these has to be selected. So basic was selected. Total is 80.
Bill Rosener: Otherwise I'm going to take a look was gold selected. Make it a hundred, and if neither one of those well, it's 120.
Bill Rosener: Then I'm gonna take a look. Okay, was tennis.
Bill Rosener: Was it set? If so, I'm going to take what was ever here. Let's assume we had a hundred gold was selected. I'm gonna take the 100 plus the 15, and add it back to total
Bill Rosener: kind of continuing on down here. Racquetball. I'm going to take my running total, possibly add 20 to it, and this would add 25 to it.
Bill Rosener: Take a look. Here is starts the form. Let me go ahead and put my name here.
Bill Rosener: Okay, we're gonna start the form. Notice we're gonna have initially in pink. And if I came over here back to this one, we're gonna start off with pink. Then we're gonna have yellow.
Bill Rosener: so that kind of should help you break you up. We're going to start a division tag floating it to the left with 130 background color pink. And then we're going to have
Bill Rosener: all of this within that div tag.
Bill Rosener: Then I'm going to start another division tag. And this one is going to be yellow, closing it.
Bill Rosener: and then we'll go ahead and add, and maybe I could
Bill Rosener: momentarily delete this one, because that's actually what we'll be working with it here in a second. So let me go ahead and save this
Bill Rosener: Kara. This is identical to what is on that image. I'm gonna come right up here and come to file.
Bill Rosener: I'm gonna go to save as.
Bill Rosener: And I'm going to go ahead and call this one assignment 4.
Bill Rosener: And I'm gonna put the.ph, dash, php, and then also
Bill Rosener: it ends with the extension dot. Php, so assignment 4 dash php, dot, php, and save that.
Bill Rosener: And here it is up here, and so if I come over here to my
Bill Rosener: looking in my desktop on tap, there it is, and if I come along and press refresh. Here it is.
Bill Rosener: and let me simply go ahead and upload that to the server, and here it is.
Bill Rosener: Now I can come back. Take a look at that.
Bill Rosener: This one was assignment 4. I'm gonna strip that off.
Bill Rosener: Take a look. Here's my assignment form.
Bill Rosener: And just like we did earlier. We got something working here. Let me go ahead and press basic calculate. Total 80.
Bill Rosener: There's a hundred and 120, and let me go ahead and choose tennis
Bill Rosener: and gold, and that should be 115.
Bill Rosener: Okay, now, what we're gonna do is go ahead and
Bill Rosener: modify this code just ever so slightly, so that when I press on basic, it instantly calls and executes and updates the total here. But to do that I'll need to do is, after all of these
Bill Rosener: right up here, right up, this is for basic.
Bill Rosener: I'm going to add on change, reload form.
Bill Rosener: Same thing here.
Bill Rosener: Same thing here. So for basic gold platinum. I change one of those option buttons. I'm gonna reload the form. This actually is a script that we have written. That's gonna I'm gonna show you here in a second, and then the same thing down here.
Bill Rosener: If tennis, this checkbox has changed, we'll reload the form
Bill Rosener: same thing on racquetball and golf. So if these values are changed, what is it going to do? It's going to come on down here. It's going to reload the form. And what's the reload, the form I'm going to do? It's going to get the element by d health club forms. If I came up here and looked at this.
Bill Rosener: Here it is. The name is the Health Club form, and also the Id. Really, in this case, it's the Id that's important. The Health Club form matches.
Bill Rosener: and all it's going to do is submit it, which is going to cause it to reload again with the new values there. So let me go ahead and save this.
Bill Rosener: Come along, come back over here. I'm gonna go ahead and right click and upload.
Bill Rosener: Let me come back to my browser.
Bill Rosener: and I can do one or 2 things I could press, refresh. But I'm gonna go ahead and really make sure I'm back. And starting with this fresh one, I'm gonna delete that
Bill Rosener: and start over. Obviously, you guys are going to keep all of your other ones. You're gonna have assignment ones 2, 3, and 4. But I just keep deleting them once I finish here. So here's assignment 4.
Bill Rosener: And now when I press basic.
Bill Rosener: can you see it went to 80, choose gold.
Bill Rosener: If you look up here you'll actually see and depend on your browser that it's a call on the server
Bill Rosener: every time those are being executed there.
Bill Rosener: Okay.
Bill Rosener: so, anyway. Let me go ahead and run through. Tell you one last thing here on. I keep doing this with javascript versus Vb. So here was all of our code
Bill Rosener: or the Php.
Bill Rosener: And if I go ahead and come over here to my browser and I go view page source.
Bill Rosener: I don't get to see any of the Php code I get to see. This is all the information used to create the form. But all of the
Bill Rosener: code they're used to create to
Bill Rosener: calculate the values is not visible there.
Bill Rosener: Okay, so anyway, take a look here, here's the assignment. 4. I have given you a code. Here's a screen capture of it again. Feel free to zoom in. I always use the control minus
Bill Rosener: and control plus on my keyboard to zoom in. Get it to the point where you can read it, and then you're gonna probably want to enter this a couple of lines at a time. Save it, upload it that way. You're not trying to.
Bill Rosener: It might make it easier before trying to track down some of any any error messages there.
Bill Rosener: So
Bill Rosener: again, I've given you the code kind of to do membership and additional charges you're going to now work on these charges to childcare personal trainers, swimming pool, and I think, having given you that code, I think you should be able to handle how to add some additional charges. Anyway, I'll catch you next video. Thanks a lot. Bye.