WEBVTT 00:00:10.740 --> 00:00:14.650 So so far we have checked all the user inputs. 00:00:14.730 --> 00:00:15.410 OK. 00:00:15.690 --> 00:00:22.670 And now you are ready to check the value of the areas variable. 00:00:23.190 --> 00:00:41.550 So if we have any errors so if errors then we can assess our results message very well to 00:00:44.710 --> 00:00:47.500 a div. 00:00:48.850 --> 00:00:53.620 OK. 00:00:59.400 --> 00:01:00.920 So are you going to give it a class 00:01:04.800 --> 00:01:06.180 let's stay in the 00:01:13.170 --> 00:01:13.470 game 00:01:18.720 --> 00:01:28.200 and we're going to place our areas variable inside case every single cause there so we can't just place 00:01:28.200 --> 00:01:28.630 it there. 00:01:28.770 --> 00:01:29.740 We have to audits. 00:01:29.790 --> 00:01:32.560 So OK 00:01:36.510 --> 00:01:37.630 here we go. 00:01:38.420 --> 00:01:42.020 OK let's take this. 00:01:42.090 --> 00:01:51.550 So let's submit the form with no values and see what we get. 00:01:51.690 --> 00:01:52.560 It's safe 00:01:57.060 --> 00:02:00.620 for us. 00:02:03.300 --> 00:02:11.250 So now if we submit the form OK we haven't printed the results message that's why we don't see anything 00:02:11.260 --> 00:02:17.180 so it's echo results message and see what we get. 00:02:17.190 --> 00:02:24.990 So if I would finish this and submit the form with no values then we can see our error message there 00:02:25.010 --> 00:02:25.230 . 00:02:25.440 --> 00:02:31.730 OK so are we missing first name last name email and password. 00:02:32.510 --> 00:02:39.130 All right so now we can write the code to executes if we have no errors. 00:02:39.360 --> 00:02:43.770 So else meaning that we have no errors. 00:02:43.790 --> 00:02:44.640 Now we are ready 00:02:47.460 --> 00:02:58.150 to create a query which we're going to run in order to insert a record to inside our table. 00:02:58.510 --> 00:03:00.820 OK. 00:03:02.460 --> 00:03:05.710 OK so now we have no errors. 00:03:06.510 --> 00:03:14.020 Are we going to do something that we call preparing variables for the query. 00:03:14.470 --> 00:03:19.870 OK so before we create the query we're going to prepare all the variables. 00:03:20.310 --> 00:03:22.830 So we're going to need the table name 00:03:26.380 --> 00:03:29.600 and that's going to be uses. 00:03:30.360 --> 00:03:31.440 OK. 00:03:32.250 --> 00:03:36.270 And all the other variables we are going to 00:03:41.700 --> 00:03:45.400 escape any special characters in those variables. 00:03:45.490 --> 00:03:46.500 OK. 00:03:46.530 --> 00:03:52.410 We're going to use a function called my Eskew a lie and the score reel as Coy's capers called string 00:03:52.420 --> 00:03:52.500 . 00:03:52.560 --> 00:03:55.040 Ok my escrow like real escapes. 00:03:55.050 --> 00:04:02.460 So this function is going to escape all special characters in a string before using a screw all statements 00:04:02.470 --> 00:04:03.080 . 00:04:03.690 --> 00:04:05.070 OK. 00:04:05.760 --> 00:04:10.750 So the way to use this function is by setting the new variable. 00:04:10.770 --> 00:04:20.040 So for example first name is going to be the output of this function. 00:04:20.040 --> 00:04:23.520 All right. 00:04:26.630 --> 00:04:33.910 And this function is going to take as a barometer a couple of. 00:04:33.910 --> 00:04:47.910 So the first barometer is going to be the connection variable which is in our case link. 00:04:50.910 --> 00:04:58.170 And the second barometer is going to be the variable to escape. 00:04:58.350 --> 00:05:02.600 Ok so which is versioning. 00:05:04.770 --> 00:05:05.590 OK. 00:05:05.970 --> 00:05:10.590 So we're going to get the escaped version for first name now. 00:05:10.820 --> 00:05:17.070 Are you going to do the same thing for the last name. 00:05:23.990 --> 00:05:29.290 It's your first name last name. 00:05:29.330 --> 00:05:30.640 Same thing for the e-mail 00:05:30.640 --> 00:05:36.410 . 00:05:36.480 --> 00:05:39.160 All right. 00:05:41.540 --> 00:05:42.830 And also the password 00:05:42.840 --> 00:05:49.040 . 00:05:55.870 --> 00:06:03.170 So regarding the passwords to store the password in a secure way we're not going to store the password 00:06:03.170 --> 00:06:06.700 in its original form it's ok or it's original form. 00:06:06.690 --> 00:06:15.570 So we're going to need to use a function which is going to calculate the hash of our password. 00:06:15.800 --> 00:06:18.520 So this function will return the hash. 00:06:18.530 --> 00:06:25.360 As a decimal number and it's called M.D 5. 00:06:25.490 --> 00:06:31.070 OK so we get to another step where password is going to be replaced with the output of this function 00:06:31.210 --> 00:06:32.710 and 5. 00:06:33.500 --> 00:06:40.970 So this function is going to take as a barometer the password and it's going to be to return the hash 00:06:40.970 --> 00:06:42.220 of the password. 00:06:42.290 --> 00:06:45.720 So they just explore what this function is doing 00:06:49.090 --> 00:06:52.780 so it's will calculate the M.D five hash of a string. 00:06:52.960 --> 00:06:55.320 OK. 00:06:55.670 --> 00:07:02.100 And it's going to return the hash as a 32 character had a small number. 00:07:02.570 --> 00:07:10.260 OK so you need to make sure that we've got enough space in our table. 00:07:10.370 --> 00:07:15.750 And if you go to the table we allowed 40 characters for the passwords. 00:07:15.800 --> 00:07:16.410 OK. 00:07:16.580 --> 00:07:24.440 If you allow less than 32 then only the first few are going to be stored on the in the table and it's 00:07:24.440 --> 00:07:26.000 going to create problems. 00:07:26.530 --> 00:07:26.950 OK 00:07:30.740 --> 00:07:39.830 OK so now that we have prepared our variables for the query we are ready to create our query and execute 00:07:39.830 --> 00:07:46.290 it so we're going to have a couple of cases depending on whether we have an ID input or not. 00:07:46.370 --> 00:07:55.550 OK so we're going to have two queries depending on whether we have the ID or not. 00:07:55.550 --> 00:07:56.990 So that's right rights 00:07:59.340 --> 00:08:06.170 execute insets queries are you going to use any says query because in setting a record in our table 00:08:06.620 --> 00:08:14.050 and we're going to check first if we are missing the ID inputs. 00:08:14.560 --> 00:08:25.370 So are you going to go to the post variable and then check the elements of the ID. 00:08:25.430 --> 00:08:32.350 So if we missing that then we're going to have the following queries so you know Colette's ask you about 00:08:33.230 --> 00:08:34.350 the variable. 00:08:34.460 --> 00:08:45.280 And we are going to insert into our table uses OK everything apart from the ID. 00:08:45.290 --> 00:08:53.360 So we get to insert the first name this major because it's all right. 00:08:53.510 --> 00:09:04.920 So we're going to insert the first name last name email and password. 00:09:06.360 --> 00:09:08.670 OK. 00:09:08.710 --> 00:09:10.970 And are going to be inserting the values 00:09:16.130 --> 00:09:23.910 to make sure that every single value is between single quotes. 00:09:25.850 --> 00:09:33.950 So the first value is going to be the value of the first name and the second one is the value of the 00:09:33.950 --> 00:09:41.380 last name and then the email and then the password. 00:09:43.450 --> 00:09:48.450 OK. 00:09:49.460 --> 00:09:53.170 And that's if we don't have an ID inputs if we have an ID puts. 00:09:53.270 --> 00:09:55.770 So else. 00:09:55.850 --> 00:10:00.690 So this is going to be slightly different. 00:10:00.770 --> 00:10:06.650 The difference is going to be the extra field. 00:10:06.740 --> 00:10:10.550 We're going to put it was just going to be the ID 00:10:13.860 --> 00:10:15.500 for the value we have 00:10:19.040 --> 00:10:21.400 the variable. 00:10:21.400 --> 00:10:26.140 Id already identified a variable ID at the beginning actually. 00:10:26.150 --> 00:10:31.940 So OK so we can replace posts Id using this variable ID in our code. 00:10:32.330 --> 00:10:37.180 So if we are missing ID. 00:10:38.900 --> 00:10:39.230 OK 00:10:43.610 --> 00:10:50.660 so now we've got our query ready to be executed. 00:10:50.880 --> 00:10:51.140 OK 00:10:55.970 --> 00:11:02.830 . 00:11:11.970 --> 00:11:15.730 OK so now let's execute our query. 00:11:15.890 --> 00:11:23.750 So we're going to use the function my is Karoli and this core query which takes a couple of premises 00:11:23.760 --> 00:11:24.870 . 00:11:24.860 --> 00:11:31.850 OK the connection object link and the query as well. 00:11:32.900 --> 00:11:33.650 OK. 00:11:33.680 --> 00:11:38.630 So rather than using the function like this we are going to check the outputs of the function. 00:11:38.630 --> 00:11:44.240 So if condition was the output of this function 00:11:49.580 --> 00:11:51.650 then our results message 00:11:54.950 --> 00:11:57.770 is going to be a success. 00:11:57.760 --> 00:11:59.640 Dave OK 00:12:02.700 --> 00:12:16.460 let's use single quotes that are going on right inside our div data added successfully 00:12:20.210 --> 00:12:25.850 to the database table and style our div using the 00:12:28.430 --> 00:12:33.530 alerts and alerts access classes. 00:12:35.350 --> 00:12:36.590 OK. 00:12:37.440 --> 00:12:46.030 And right after this we need to echo the results message. 00:12:47.080 --> 00:12:47.950 OK. 00:12:48.080 --> 00:12:53.510 Otherwise if there was any problem then we are going to say. 00:12:53.510 --> 00:12:58.100 Else we are going to 00:13:04.410 --> 00:13:10.670 set our results message to another volley. 00:13:13.150 --> 00:13:16.000 It's going to use alerts alerts warning. 00:13:17.510 --> 00:13:22.760 And this time we are going to say error. 00:13:23.780 --> 00:13:36.780 Unable to executes and he writes the name of the or the value of the query. 00:13:36.890 --> 00:13:46.850 Q Well we can with that because you are using single quotes so he's going to do this. 00:13:53.210 --> 00:13:53.550 OK. 00:13:53.550 --> 00:13:54.530 And then we're going to add 00:13:58.430 --> 00:14:00.150 the error 00:14:01.650 --> 00:14:04.440 . 00:14:08.710 --> 00:14:19.040 And the area is going to be my Escurial II and this call error is going to be the output of this function 00:14:19.040 --> 00:14:23.470 which will take as a barometer our connection objects. 00:14:23.470 --> 00:14:24.630 OK. 00:14:25.120 --> 00:14:28.950 And it's these this. 00:14:29.630 --> 00:14:34.150 That's OK. 00:14:34.220 --> 00:14:40.160 And finally we need to echo the results message as well. 00:14:40.430 --> 00:14:45.980 We could have only one statesman's for echoing the results message right at the end because in all cases 00:14:45.980 --> 00:14:47.550 we are ignoring it. 00:14:47.570 --> 00:14:51.340 But anyway let's leave it like this for now and Tess's. 00:14:51.710 --> 00:14:52.250 So 00:14:55.550 --> 00:14:59.210 let's go back to our page refresh. 00:15:00.080 --> 00:15:16.800 OK so if we submits a first name piece for example the last name Tyla and email Peter G.M. has come 00:15:16.810 --> 00:15:19.690 for example and then a password. 00:15:21.180 --> 00:15:23.940 And if you click on send data. 00:15:25.180 --> 00:15:25.650 OK. 00:15:25.910 --> 00:15:32.390 So we've got a warning message saying unable to execute this query so let's check what's wrong with 00:15:32.390 --> 00:15:34.190 the query. 00:15:35.510 --> 00:15:38.770 OK so are we missing. 00:15:38.870 --> 00:15:44.570 As in the first name is it the same here. 00:15:45.540 --> 00:15:49.260 So let's let's try again. 00:15:50.120 --> 00:15:53.120 So Peter Tyler 00:15:56.520 --> 00:16:02.090 is an e-mail passwords. 00:16:04.430 --> 00:16:06.680 It's in data. 00:16:07.310 --> 00:16:09.840 OK so data out successfully be stable. 00:16:09.980 --> 00:16:17.900 So now let's check that in our table so that OK we need to log in again on 00:16:23.530 --> 00:16:24.400 this one 00:16:25.520 --> 00:16:30.490 . 00:16:35.660 --> 00:16:41.870 OK so we have the access table. 00:16:44.510 --> 00:16:50.610 And it's looking again for some reason. 00:16:55.330 --> 00:17:02.460 So if I access the table now looks like something is wrong again 00:17:02.750 --> 00:17:08.420 . 00:17:09.710 --> 00:17:17.280 OK so now if you go to Escurial and then click on go then we can see the details inside I would say 00:17:17.340 --> 00:17:19.520 you can see and you recall there. 00:17:19.640 --> 00:17:25.150 OK you can try again at another record. 00:17:25.310 --> 00:17:27.860 So let's give it this time an ID 7. 00:17:28.520 --> 00:17:31.030 And this is a first name. 00:17:31.460 --> 00:17:38.390 George for example the last name because the email 00:17:41.710 --> 00:17:44.600 and a password. 00:17:45.260 --> 00:17:49.610 If you send a data so this out successfully 00:17:52.290 --> 00:17:57.940 this check and we can see the new record there. 00:17:58.340 --> 00:18:08.130 OK just one thing you can see that's because our passwords good at that as a 30 32 character. 00:18:08.670 --> 00:18:11.590 It's an exit a dismal performance. 00:18:11.600 --> 00:18:13.890 OK. 00:18:16.550 --> 00:18:21.400 So that's how we can populate our table using an email form. 00:18:21.780 --> 00:18:22.610 OK. 00:18:22.640 --> 00:18:30.290 In the next video we're going to learn how to retrieve data from our from our table