Placeholder Image

Subtitles section Play video

  • creating these classes requires equipment and service.

  • Is that cost money?

  • If you appreciate this education, please think about going to Eli the computer guy dot com and offering a one time or monthly recurring donation.

  • Welcome back.

  • As you know why, I'm Eli, the computer guy, and in today's class, I'm going to show you how to insert records in here my sequel, database table using an HTML form.

  • So we're going to be using a number of different forms of technology today.

  • We're going to be using an HTML form that HTML form.

  • You're going to input data into it.

  • You're going to hit this button and then that Hmm.

  • Oh, form will then hand that data over to a P A P script.

  • PHP script will parse the data that it has been provided, turned the data into variables and then use equal in order to insert that into your my sequel database table.

  • So this is one of those places where people ask me, you know, Eli, you know what language do I need to learn to become a technology professional?

  • And, as you can see, even with something as simple as an input form, that then puts information into a database.

  • We're dealing with three different languages here we're doing with HTML.

  • We're dealing with PHP, and we're dealing with my sequel.

  • So, using those different languages, I'm going to show you how to create a form today so that you can insert records into your my single database tables.

  • So the warning warning for today is simply to remember that we are going to be using multiple different technology products in order to develop the demonstration that we will be coding to today.

  • Why that is important is because in any of these different products, you may, uh, code something out improperly, and then everything will fail.

  • So HTML has a specifics intact.

  • So there's a specific way that you write html code in order for to do what it's supposed to do.

  • There is a specific way that you write PHP code for it to do what it's supposed to do.

  • There's a specific way that you you write my sequel statements or sequel statements in order for the sequel statements to do what they're supposed to do.

  • There's also things second user privileges within your mind sequel database, all kinds of different things going on.

  • So do just realize when you're trying to do the demonstration project today, if you come to any errors, if you come to any problems, just go back and just recheck all of your code.

  • Go back, re verify everything, go back and do a basic troubleshooting.

  • Because what you might find is that you simply forgot a very, very small thing.

  • And now all the code that your written simply isn't doing what it's supposed to do.

  • So just realize when you're doing the project today, we're dealing with HTML.

  • We're dealing with PHP.

  • We're dealing with sequel.

  • We're also dealing a Paki were also the 11 Lennox.

  • We're also actually dealing with the my sequel database software.

  • So all of these things have to work together simply for you to be able to do something as simple as creative form and be of the input data into your my sequel database tables using a PHP script.

  • So with that, let's go over to the computer and I will show you how all this works.

  • So here we are, at my lab set up, as always, have a bunch of desktop 18.4 Lt s running.

  • I haven't running within a virtual machine in virtual box.

  • And this is on my Mac book Pro.

  • I have used tasks l t A s K S E l in order to install the entire lamp stack onto this ribbon, too.

  • Desktop operating system.

  • So I have Apache in my sequel on PHP.

  • I have not modify any of the default configurations other other than to simply put a PHP folder in the route for the Apache of Public Directory.

  • Otherwise, I have not modified Pete, Pete and I and I v hosts or anything like that I'm using in order to code the little HTML and the PHP for today.

  • I am simply using G Edit.

  • This is just a basic text editor, because again, when we're doing these simple projects, I like using the simplest text editor possible.

  • So you don't have to learn an entirely new product simply to do something such as Creed and HTML, for the first thing we're going to do today, as always, is we're going to go over to our my sequel database just to make sure you know what is going on with our my sequel databases.

  • You go down to the apse, you put terminal into the search bar.

  • As always, that brings up the command prompt.

  • And what we're going to do is simply first log into my sequel.

  • My sequel.

  • Space, You user name.

  • Space hyphen, P passwords.

  • Anything we've done 1000 times.

  • Password up.

  • 123456 Because I'm super secure that way a tous point again.

  • We always have to verify.

  • We know what's going on with our database.

  • When you're writing code, you have to write, you know, the specific database, the specific table.

  • If you if you misspell something, then it's simply not correct.

  • The computer cannot guess what you mean.

  • You have to.

  • It's either right or it's wrong.

  • There's no there's no close.

  • You know, you don't get a B and programming languages.

  • You either get an A plus or an F s.

  • So the first thing we need to do is show that base is just to make sure what databases we're dealing with.

  • Then we go through here and see the standard databases, and then we have the Class D B and Class D B backup.

  • So the class the bee is the database that we're using, or at least that I am using something audio use class or case D B semi colon is always that brings us into the class D B from here.

  • Would you show tables?

  • Semi colon.

  • I'm gonna go in here and see what the tables are.

  • A whole bunch of tables at this point, because again, I've been using this database server for all the classes up until now.

  • So we have insert demo parts, all kinds of stuff.

  • The table that we're going to be dealing with today is the students table students table.

  • You will notice I have created a student's table back up.

  • So students underscore B A.

  • K is a backup of the students table in case I screw anything up.

  • So I would ah, highly advise if you're gonna be dealing with tables, especially with coding that you create a backup so that if you have to believe the entire table, you have something to go back to you rather quickly.

  • Ways We have the students table here.

  • So the first thing we're going to do is we're simply going to describe the S c the students table to verify what this even still today.

  • Verify what the students table looks like.

  • So you click here and okay, so we can see a student.

  • I d We're not gonna mess with this.

  • This is an integer.

  • It's a primary key, and this is what you auto increments.

  • So basically, this is kind of like a user i d number.

  • So you always verify you have you have one absolutely unique feel for every record.

  • So you don't come into any problems.

  • Then we have the name, field, all lower case name that is a text type with a field that is an inter type way, have a gender field, and that is a text type S O.

  • Today.

  • What we're going to be dealing with is we're gonna be dealing with the name field, the age field and the gender field.

  • We won't be with the uniform field.

  • Then we need to go in.

  • We do select all from students just to see what the records look like.

  • Semi colon And how we can see I have a lot of different records in here.

  • So again, I've been playing around with a script just to make sure the script works and so we can see the different names here.

  • You see the different ages here See the different genders here.

  • Eso basically now we know what How, what the schema of the table looks like again what the column names with the data types are.

  • And we also verify that there are records in this table so that when we add records to this table, we know that we're actually doing something s so that all looks good to us.

  • So now let's go over.

  • Take a look at the first thing that we need to dio is create an HTML for right So the html for more time out html form.

  • This is just the basic really, really, really crappy HTML forms have already saved this.

  • So we goto 1 27.0 point 0.1 That is a look back address the PHP phoner Ford slashed form dot html That's what I've saved this for mass.

  • And so what this code here knows is it creates this very ugly for here and again.

  • This is where so I don't have any CSS here.

  • I don't even have any javascript here.

  • So when we talk about how many languages are required in order to create even even the most simple application again.

  • You really do.

  • You truly need to know about five languages, at least just to really start doing much of anything, at least in the Web app development world.

  • Anyway, so we want to create this form.

  • Here s we're going to have a feel for the name we're going to feel for the age and we're going to have a feel for the gender.

  • You'll notice Name and age are simply text blocks and then for a gender.

  • What I did is I plugged in, boy or girl, this is a way of simply just doing like data validation.

  • So if you're putting in something like gender, especially if you're gonna be doing queer, he's off of it.

  • You don't want one person put in female?

  • What person?

  • Putting girls on one person to put in a woman.

  • One person put him boy.

  • One person to put a man on one.

  • Put it.

  • You know, that's one of the things you have to think about is you need to make sure if you're gonna be doing queries off with the data that's being submitted.

  • That that it gets standardized as possible.

  • So one of things I've done here is I've simply put in an option Boxes you can either select boy or girl.

  • So again, I don't have some people putting in female.

  • Some people put in girls you're putting in a woman holding.

  • So anyways, this is a form that we're gonna be created here.

  • So we go down, we took a look.

  • Take a look at this HTML code and it's really, really, really simple.

  • That's the first thing again.

  • You open up the HTML tags, he normally d'oh!

  • And then I'm simply opened up the body tag, not dealing with a head tag today because again, we're just creating a stupid little form.

  • The first thing we're going to do is we're gonna create form.

  • So we're going to open up the form tag and they're gonna do action equals.

  • And so any here, this is going to be the name of the P eight p script that you're going to be passing the data to.

  • And then this PHP script will turn that data into variables and then do with it whatever it's gonna do.

  • Now, what you'll notice here is this as PHP All uppercase test, eh?

  • So what I'm actually doing here is I'm going to use the test script that have created simply to verify that the HTML form is in fact passing the variable values over to PHP and PHP is actually able to parse everything on I'm going to have a just print out on the screen.

  • So again, one of things have to be thinking about in the real world is creating trouble shooting routines.

  • So the first thing that I'm going to do is I'm going to show you how this form passes, passes the values to PHP.

  • And then all PHP is gonna do is print it out to the screen.

  • We're gonna verify that works.

  • And then once we verify that works, then I will show you the actual script that will take those those values and actually passed them to my sequel database s o the action.

  • This is just whatever the script name is on again.

  • Do you remember uppercase lower case?

  • All of that has to be correct.

  • So P h p t e s t all lower case is a different file than PHP.

  • Lower case t e s t uppercase that p a p method post.

  • See, there is post and get.

  • I'm showing you post today.

  • People can argue about that.

  • I'm just going to show you post, then passed That we're gonna look at it is so now just basic text.

  • I'm not dealing with tags or no h water p tags or anything, so I just do name Colon.

  • Just print that on on the screen on.

  • That's what you get here.

  • If you don't use any tags at all on, then we're going to input type.

  • Equals is the input type is text s.

  • That's basically saying it's just a text box and then name equals what is the name of this particular variable?

  • So when we pass this, how are we actually going to be a great how are we going to reference this in the p A piece grip?