WEBVTT 00:00:07.080 --> 00:00:09.190 Now we need to connect to the database. 00:00:09.210 --> 00:00:09.820 OK. 00:00:09.840 --> 00:00:14.050 So we need to do this as we're going to be running some queries later on. 00:00:14.100 --> 00:00:14.880 OK. 00:00:15.030 --> 00:00:17.160 In the users table. 00:00:17.160 --> 00:00:21.120 So to do this you need to go back to our database. 00:00:21.240 --> 00:00:21.720 OK. 00:00:21.770 --> 00:00:24.210 You go into the C panel and then why is Google databases 00:00:27.600 --> 00:00:33.810 and you need the name of our database and the name of the user. 00:00:34.080 --> 00:00:34.700 OK. 00:00:35.010 --> 00:00:37.600 So that's the user database. 00:00:38.040 --> 00:00:44.700 OK we are going to need also the password that we generated earlier so 00:00:48.570 --> 00:00:51.180 to connect to the database we're going to create a variable. 00:00:51.220 --> 00:00:55.210 Ok called Link. 00:00:55.560 --> 00:00:56.080 OK. 00:00:56.250 --> 00:01:00.180 And inside this variable we can to all the outputs of the function. 00:01:00.520 --> 00:01:04.580 Ok my escrow Malloy connects. 00:01:05.340 --> 00:01:07.940 So this function is going to take four parameters. 00:01:07.940 --> 00:01:11.190 So the first barometer is going to be the host. 00:01:11.250 --> 00:01:11.740 OK. 00:01:11.790 --> 00:01:17.290 In our case we are using the local host so it's going to be local house. 00:01:17.400 --> 00:01:19.810 The second promiser is the user. 00:01:20.150 --> 00:01:20.870 OK. 00:01:21.540 --> 00:01:28.210 So in our case the user is mine. 00:01:28.590 --> 00:01:30.490 No it's not. 00:01:31.710 --> 00:01:32.790 OK. 00:01:33.480 --> 00:01:39.460 And the third one is going to be the password. 00:01:44.470 --> 00:01:49.020 And then the last one is the name of our database. 00:01:49.020 --> 00:01:52.550 In our case going for this one. 00:01:52.560 --> 00:01:57.470 So it is just that. 00:02:01.240 --> 00:02:03.370 OK. 00:02:06.150 --> 00:02:11.160 So now we're going to check if the connection is successful. 00:02:11.190 --> 00:02:12.230 OK. 00:02:13.950 --> 00:02:23.070 So to do this we're going to check the outputs of the error function or connection error function which 00:02:23.070 --> 00:02:27.340 is my school-I connects error. 00:02:28.330 --> 00:02:31.170 Ok so if we get any errors 00:02:39.360 --> 00:02:48.960 then we are going to use the function by OK which will print something and stop the whole page peacoat 00:02:48.970 --> 00:02:49.060 . 00:02:49.140 --> 00:02:50.580 OK. 00:02:52.620 --> 00:02:54.870 So we're going to write some something like this 00:03:00.120 --> 00:03:05.020 error unable to connect with them. 00:03:06.600 --> 00:03:07.990 And also if you wants. 00:03:08.160 --> 00:03:14.540 For testing purposes you can get the actual error returned by this function. 00:03:15.060 --> 00:03:15.250 Ok 00:03:20.410 --> 00:03:24.060 we'll soon need to connect in other files. 00:03:24.060 --> 00:03:26.130 So to avoid repetition. 00:03:26.250 --> 00:03:29.650 Well we're going to do we're going to copy this code. 00:03:29.840 --> 00:03:34.060 OK. 00:03:35.400 --> 00:03:44.050 Inside a file thus we're going to call connection those BHB and then we're going to include this file 00:03:44.060 --> 00:03:44.290 . 00:03:44.520 --> 00:03:45.330 OK. 00:03:45.450 --> 00:03:46.830 Inside our assignment file 00:03:52.230 --> 00:03:53.460 We're going 00:04:04.020 --> 00:04:05.280 to open this file 00:04:12.940 --> 00:04:14.550 and copy the code inside 00:04:14.570 --> 00:04:20.380 . 00:04:26.070 --> 00:04:26.290 OK 00:04:26.530 --> 00:04:33.400 . 00:04:34.440 --> 00:04:36.900 Now we are ready to check the user inputs. 00:04:36.920 --> 00:04:43.020 OK so the first step we're going to do here is defining error messages. 00:04:43.020 --> 00:04:44.990 So these are any potential errors. 00:04:45.000 --> 00:04:48.550 Ok then the user might encounter when trying to sign up. 00:04:48.870 --> 00:04:50.370 So we're going to store them inside 00:04:52.730 --> 00:04:53.650 variables. 00:04:53.760 --> 00:04:54.510 OK. 00:04:54.810 --> 00:05:00.370 So the first error would be missing using. 00:05:01.860 --> 00:05:02.860 OK. 00:05:03.550 --> 00:05:07.290 I them inside a paragraph 00:05:12.510 --> 00:05:14.300 OK. 00:05:16.400 --> 00:05:19.330 So we're going to place each era inside a paragraph OK. 00:05:19.490 --> 00:05:26.270 And at the end when we process the code we can place all these paragraphs inside a day like this. 00:05:26.270 --> 00:05:26.560 OK. 00:05:26.570 --> 00:05:30.980 And we can decorate it using the alerts colors danger glasses. 00:05:31.040 --> 00:05:31.580 OK. 00:05:31.970 --> 00:05:38.030 So the next one is missing e-mail. 00:05:39.220 --> 00:05:40.050 OK. 00:05:40.490 --> 00:05:43.820 And then invited e-mail 00:05:46.830 --> 00:05:48.500 then missing password 00:05:48.500 --> 00:05:55.940 . 00:05:55.940 --> 00:05:58.410 Also we can go for invalid password. 00:05:58.520 --> 00:05:58.880 OK. 00:05:58.910 --> 00:06:03.070 If we add some requirements our password like having at least one digit. 00:06:03.260 --> 00:06:07.450 Well stuff like those. 00:06:10.730 --> 00:06:15.980 And also we're going to be checking that's the these two passwords much. 00:06:16.070 --> 00:06:18.030 OK. 00:06:19.700 --> 00:06:26.230 And finally if we miss password to going to say missing password too. 00:06:28.330 --> 00:06:29.020 OK. 00:06:29.490 --> 00:06:36.350 And you can choose the wording for each of these paragraphs to save time I've copied my wording straight 00:06:36.350 --> 00:06:36.720 away. 00:06:36.770 --> 00:06:37.770 OK. 00:06:37.790 --> 00:06:40.800 Feel free to change us as you like. 00:06:40.820 --> 00:06:48.620 So a couple of comments so the password is going to have a few requirements we're going to need at least 00:06:48.620 --> 00:06:49.700 six currencies. 00:06:49.870 --> 00:06:50.290 OK. 00:06:50.360 --> 00:06:54.670 And we're going to need one capital letter and at least one number. 00:06:55.470 --> 00:06:56.130 OK. 00:06:56.190 --> 00:07:02.320 And I have added the strong tank to make the text look bold. 00:07:02.360 --> 00:07:03.960 OK. 00:07:05.690 --> 00:07:07.360 Now let's get the user inputs. 00:07:07.550 --> 00:07:08.960 So it starts with the username 00:07:09.020 --> 00:07:14.650 . 00:07:15.140 --> 00:07:18.780 So first we're going to check if the user has actually submitted a username. 00:07:18.800 --> 00:07:24.000 So to do this we're going to use a function called is set. 00:07:24.200 --> 00:07:34.910 So this function is going to check if we have inside the most sensitive array a value corresponding 00:07:34.910 --> 00:07:37.650 to the elements using it. 00:07:38.490 --> 00:07:39.610 OK. 00:07:40.220 --> 00:07:46.730 So we can check the opposites using an exclamation mark. 00:07:46.850 --> 00:07:47.480 OK. 00:07:48.020 --> 00:08:01.340 So if the user name is not set we're going to add the error corresponding to missing using the OK to 00:08:01.340 --> 00:08:04.030 a variable that we're going to call errors. 00:08:04.220 --> 00:08:07.810 Ok so initially this variable is going to be empty. 00:08:07.880 --> 00:08:08.530 OK. 00:08:08.540 --> 00:08:13.850 So if the username is missing meaning to add this paragraph to this variable. 00:08:13.850 --> 00:08:14.430 OK. 00:08:15.020 --> 00:08:27.260 Else we are going to store the filtered variable inside a variable called use any. 00:08:27.890 --> 00:08:33.770 So to filter the user name we're going to use the function filter underscore var. 00:08:34.270 --> 00:08:38.550 OK so if you remember this function is going to take a couple of promises. 00:08:38.630 --> 00:08:43.500 So the first promiser is going to be the value to filter. 00:08:43.810 --> 00:08:44.100 OK. 00:08:44.170 --> 00:08:46.500 In our case flows you get. 00:08:47.170 --> 00:08:54.680 And the second promiser for a string is going to be filter and the score Sonny size strength. 00:08:54.990 --> 00:08:57.810 OK. 00:08:58.730 --> 00:09:00.500 Now let's get the e-mail. 00:09:00.920 --> 00:09:01.220 OK 00:09:01.240 --> 00:09:06.930 . 00:09:10.920 --> 00:09:21.820 So we're going to do exactly the same things are going to check if the email ok is set. 00:09:27.850 --> 00:09:28.840 OK. 00:09:29.270 --> 00:09:32.510 And it's use next mark as well. 00:09:33.100 --> 00:09:33.570 OK. 00:09:33.630 --> 00:09:41.420 So if the e-mail is missing we're going to the error is variable. 00:09:41.880 --> 00:09:45.560 Ok the error corresponding to missing email 00:09:50.210 --> 00:09:50.440 ok 00:09:55.590 --> 00:10:05.760 else if the e-mail is provided then we're going to filter our e-mail OK and store the results in a variable 00:10:05.780 --> 00:10:05.830 . 00:10:05.850 --> 00:10:06.900 We're going to call email. 00:10:07.080 --> 00:10:07.910 OK. 00:10:07.980 --> 00:10:14.760 So again we're going to use the function filter var and he's going to take a couple of dynamics. 00:10:14.760 --> 00:10:26.080 So the first one is going to be the email and the second barometer is going to be filter Sonny size 00:10:28.310 --> 00:10:29.430 e-mail. 00:10:30.240 --> 00:10:33.570 OK. 00:10:34.500 --> 00:10:37.500 All right so now we filtered the e-mail. 00:10:37.740 --> 00:10:38.840 OK. 00:10:39.750 --> 00:10:43.270 Now we're going to check if it's actually a valid e-mail. 00:10:43.350 --> 00:10:43.790 OK. 00:10:43.980 --> 00:10:51.290 So to do this we're going to use again the filter function 00:10:51.300 --> 00:10:58.170 . 00:10:58.690 --> 00:11:00.250 OK. 00:11:01.590 --> 00:11:04.010 Let's begin a couple of times again. 00:11:04.020 --> 00:11:05.970 So the first one is the actual e-mail. 00:11:06.050 --> 00:11:06.370 OK. 00:11:06.480 --> 00:11:11.210 As we start inside the e-mail the variable and the second Brahmi said this time is going to be filtered 00:11:11.320 --> 00:11:13.140 Vonni D.C.M.. 00:11:13.400 --> 00:11:16.370 This is going to validate our e-mail. 00:11:16.590 --> 00:11:17.340 OK. 00:11:18.000 --> 00:11:20.790 So we can use the exemption walk. 00:11:20.920 --> 00:11:22.890 OK to check the opposite. 00:11:22.890 --> 00:11:26.250 So if the e-mail is not valid then 00:11:31.230 --> 00:11:34.190 we're going to areas variable 00:11:38.730 --> 00:11:43.830 the error corresponding to invalid e-mail. 00:11:45.550 --> 00:11:47.090 OK. 00:11:47.760 --> 00:11:49.500 Now let's get the last word. 00:11:49.680 --> 00:11:50.030 OK 00:11:50.030 --> 00:11:59.470 . 00:12:00.300 --> 00:12:01.420 All the passwords. 00:12:01.500 --> 00:12:02.080 OK. 00:12:02.460 --> 00:12:09.180 So let's check first if the user somebody said the first password 00:12:12.000 --> 00:12:14.700 . 00:12:17.030 --> 00:12:23.940 Me checking the value corresponding to password. 00:12:25.500 --> 00:12:27.450 OK. 00:12:28.770 --> 00:12:33.330 If you remember we named this field password and that's one password too. 00:12:33.420 --> 00:12:34.620 OK. 00:12:34.620 --> 00:12:41.950 All right so if it if the password is missing so it's using an exclamation mark for the opposite. 00:12:42.360 --> 00:12:49.160 All right then we're going to add to the errors variable. 00:12:49.170 --> 00:12:56.930 Ok the error corresponding to missing password. 00:13:01.210 --> 00:13:01.500 OK 00:13:06.090 --> 00:13:06.880 else. 00:13:07.220 --> 00:13:17.100 OK we are going to check if the submitted password verifies all the requirements. 00:13:17.100 --> 00:13:22.330 So the first one is the password needs to be at least six characters. 00:13:22.500 --> 00:13:29.240 And then we want the bus which include at least one cup has a letter and at least one number OK or one 00:13:29.280 --> 00:13:30.340 digits. 00:13:31.050 --> 00:13:32.040 So we're going to use. 00:13:32.040 --> 00:13:32.910 Else. 00:13:33.420 --> 00:13:34.480 OK. 00:13:35.010 --> 00:13:36.770 I was going to have no what else. 00:13:36.840 --> 00:13:43.810 So we're going to check if the length of the password is less than six. 00:13:43.980 --> 00:13:45.790 OK. 00:13:46.620 --> 00:13:49.760 Other ways we can dispute all the good conditions. 00:13:49.920 --> 00:13:50.390 OK. 00:13:50.490 --> 00:13:53.440 And then we can add an exclamation mark. 00:13:53.700 --> 00:13:54.440 OK. 00:13:54.690 --> 00:13:58.020 Before the conditions to check the. 00:13:58.530 --> 00:14:01.830 So to check the length of the password we're going to use the function. 00:14:02.400 --> 00:14:03.470 England. 00:14:04.050 --> 00:14:05.210 OK. 00:14:06.860 --> 00:14:10.940 So they're going to take the letters of those password. 00:14:11.710 --> 00:14:12.460 OK. 00:14:12.700 --> 00:14:20.470 And you're going to check if that's greater than six. 00:14:23.120 --> 00:14:23.850 OK. 00:14:24.110 --> 00:14:32.420 And the second condition is that's the password includes at least one copy of the letter. 00:14:32.430 --> 00:14:34.720 So you cannot use a rejects for this. 00:14:34.940 --> 00:14:38.460 So the function to use is break much. 00:14:38.580 --> 00:14:39.430 OK. 00:14:39.840 --> 00:14:41.230 It's going to take a couple of time. 00:14:41.250 --> 00:14:48.800 So the first one is going to be the red X and the second one is the value that we are taking which is 00:14:48.810 --> 00:14:49.880 post password. 00:14:50.310 --> 00:14:55.240 So the Rejects for a capital letter is going to be us following. 00:14:55.860 --> 00:15:06.240 We're going to have between brackets OK a minus sign is at the capital a computer it. 00:15:06.540 --> 00:15:07.930 OK. 00:15:09.270 --> 00:15:11.340 And the last condition 00:15:14.670 --> 00:15:17.960 you use that is the same syntax 00:15:43.360 --> 00:15:49.430 it well instead of a to said you're going to use 0 2 9. 00:15:50.670 --> 00:15:51.180 OK. 00:15:51.330 --> 00:15:55.710 And making sure that the password includes one digits at least 00:15:58.920 --> 00:16:01.570 so the condition is going to and here. 00:16:01.860 --> 00:16:02.580 OK. 00:16:02.940 --> 00:16:08.540 And we're going to be checking the opposites. 00:16:10.250 --> 00:16:12.910 All right. 00:16:13.370 --> 00:16:19.200 I am going to need one plans to close this one. 00:16:20.220 --> 00:16:22.570 OK. 00:16:24.600 --> 00:16:27.720 Now if there is an error 00:16:30.490 --> 00:16:41.240 the error is variable the error corresponding to invalid password. 00:16:43.910 --> 00:16:44.900 OK. 00:16:45.240 --> 00:16:55.230 Now if the password is valid OK then we're going to filter the password and store it inside an invaluable 00:16:55.650 --> 00:16:57.670 password. 00:16:59.280 --> 00:17:09.960 OK you use again the function filter Val you know a couple of Thomasis are the first one is the password 00:17:12.070 --> 00:17:13.190 and the second one 00:17:16.120 --> 00:17:25.810 is going to be able to sanitize the string. 00:17:30.270 --> 00:17:34.440 Now we're going to check if the second password is missing. 00:17:34.500 --> 00:17:35.520 OK. 00:17:36.420 --> 00:17:39.790 I'm going to stay inside this block of code. 00:17:39.990 --> 00:17:45.300 So if the second password is missing 00:17:50.180 --> 00:17:53.350 then we're going to add another error. 00:17:54.130 --> 00:17:57.980 Otherwise we're going can do something else. 00:17:58.200 --> 00:18:03.860 So we're going to do exactly the same thing we did for the first password. 00:18:06.880 --> 00:18:12.360 So the condition is the same. 00:18:12.530 --> 00:18:16.800 Are we looking here at password too. 00:18:18.010 --> 00:18:20.750 OK. 00:18:22.300 --> 00:18:31.190 So it does password is missing we going to add this is going to be areas variable missing password too 00:18:31.200 --> 00:18:32.800 . 00:18:34.500 --> 00:18:35.790 OK. 00:18:36.870 --> 00:18:44.260 Otherwise we're going to filter this password and then compare it with the first password. 00:18:44.580 --> 00:18:49.010 So it feel to the post-wedding and in exactly the same thing we did for the first password and it's 00:18:49.030 --> 00:18:54.330 always in a variable password too. 00:18:56.080 --> 00:18:58.100 OK. 00:19:01.140 --> 00:19:06.240 Now we're going to check if the two passwords are the same 00:19:11.760 --> 00:19:12.480 password 00:19:16.200 --> 00:19:24.230 is different from password 2. 00:19:27.300 --> 00:19:30.400 Ok then we're going to add another error 00:19:34.140 --> 00:19:41.050 and this time it's going to be different Spotswood. 00:19:41.240 --> 00:19:43.820 All right. 00:19:43.830 --> 00:19:47.550 All right so in the next video we're going to check if there are any errors and then display an error 00:19:47.550 --> 00:19:47.920 message. 00:19:47.940 --> 00:19:48.640 If that's the case