WEBVTT 00:05.390 --> 00:15.980 So first we are going to start a session using the session starts function because you're going to be 00:15.980 --> 00:19.110 using some session variables later. 00:19.640 --> 00:27.790 And also you're going to connect to the database by including the connection file. 00:27.890 --> 00:36.190 So we need to connect so that we can run queries later on and on a new record to the table. 00:36.530 --> 00:37.240 OK. 00:37.370 --> 00:42.180 So first as usual I'm going to find all the error messages. 00:44.310 --> 00:53.080 So the possible error message is that we're going to potentially get here I'm going to be something 00:53.080 --> 00:59.000 like missing the Parcher or involve departure. 00:59.210 --> 00:59.680 OK. 00:59.820 --> 01:05.570 So are you going to get an evolved departure if the departure is that the coordinates are not there. 01:05.670 --> 01:06.270 OK. 01:06.270 --> 01:11.130 Because the Stations of the geocoder request has failed or. 01:11.610 --> 01:18.290 Going to have similarly a missing destination or invite this nation missing price or Mbali price. 01:18.300 --> 01:28.130 If you have something other than this it's also missing seats available or invalid seats available missing 01:28.130 --> 01:33.330 frequency if the user doesn't select any of these two radio buttons. 01:33.590 --> 01:34.390 OK. 01:34.810 --> 01:41.240 And also if the trip is regular and the user doesn't select any of these then we're going to say that's 01:41.300 --> 01:48.380 because missing dates because we need to select at least one of these if the trip is regular and if 01:48.440 --> 01:51.530 it's a one off trip the data is missing. 01:51.530 --> 01:58.940 We're going to have a missing data era and in most cases we're going to have a missing time if the user 01:59.180 --> 02:01.840 doesn't provide the time of the trip. 02:02.060 --> 02:04.430 OK so let's start with the first one 02:07.220 --> 02:09.260 missing departure. 02:15.190 --> 02:23.010 So we're going to place all these areas inside a paragraph and then later on when we want to echo the 02:24.360 --> 02:27.890 error variable then we're going to place everything inside a div. 02:27.900 --> 02:33.030 Are we going to give it some proper styling using some classes like the alerts and there is danger. 02:33.420 --> 02:36.390 OK so we're going to have a photograph where each 02:39.430 --> 02:45.710 and for this one and it's when it's odd these strong snags to make these bold 02:53.290 --> 03:01.460 OK and this might something like Please enter your departure. 03:01.910 --> 03:02.340 OK. 03:02.570 --> 03:08.140 So as I have discovered all the possible errors. 03:08.150 --> 03:08.880 OK. 03:08.900 --> 03:13.900 I'm going to post the video and just type all the rest to save you time. 03:14.390 --> 03:15.020 OK. 03:15.020 --> 03:22.000 And I suggest you just continue on your side and you write all the possible error messages right now 03:22.000 --> 03:23.410 cause all the error messages. 03:23.450 --> 03:23.950 OK. 03:24.380 --> 03:26.000 I hope that you know something similar. 03:26.150 --> 03:30.550 So now I'm ready to get all the inputs. 03:30.770 --> 03:34.310 OK. 03:37.430 --> 03:37.990 OK. 03:38.280 --> 03:46.210 So if the user gets to this file then they would have definitely clicked on that button. 03:46.490 --> 03:46.770 OK. 03:46.800 --> 03:50.010 Which sends an eight us call to our page people. 03:50.330 --> 04:00.080 So I'm going to go straight away and define variables where I'm going to place all the posts elements 04:02.110 --> 04:07.020 like this saucing would be OK 04:11.510 --> 04:13.740 and then the destination. 04:13.770 --> 04:21.810 And then the price seats available and so on and for each we just need to use the name of that specific 04:23.040 --> 04:23.600 field. 04:23.670 --> 04:24.330 OK. 04:24.330 --> 04:26.370 So again this is pretty straightforward. 04:26.400 --> 04:30.480 To save time I'm going to post the video again and you can just do this on your own. 04:30.480 --> 04:30.810 OK. 04:30.930 --> 04:32.280 So I'm going to pause now. 04:32.740 --> 04:33.030 OK. 04:33.030 --> 04:36.010 So we've got all our inputs. 04:36.810 --> 04:39.070 Well basically we are missing the coordinates. 04:39.530 --> 04:39.950 OK. 04:40.050 --> 04:46.410 So for these ones we don't need to check if these are set before defining a variable and storing the 04:46.410 --> 04:48.510 Post's elements inside the variable. 04:48.690 --> 04:54.060 OK because if the user gets to this page before we are sure that they have clicked on that person and 04:54.060 --> 04:56.270 we are sure that they have submitted that form. 04:56.490 --> 04:56.920 OK. 04:57.180 --> 05:05.340 So now we're going to need to start looking into each of these variables. 05:05.340 --> 05:05.790 OK. 05:05.820 --> 05:08.150 And then check if you got any errors. 05:08.520 --> 05:17.520 And then when we are looking at the departure for example then we will see if the coordinates are set 05:17.610 --> 05:18.460 or not. 05:18.650 --> 05:19.800 OK. 05:19.850 --> 05:20.090 So 05:23.680 --> 05:25.170 so I would just take the departure 05:27.870 --> 05:30.660 and see if we got any errors. 05:34.970 --> 05:41.230 So we're going to check if the variable departure is empty. 05:43.280 --> 05:54.730 Then we're going to get to the areas variable the area corresponding to missing departure. 05:55.570 --> 05:57.080 OK. 05:57.140 --> 06:06.550 Otherwise if that's not empty then that means that we need to look at the coordinates. 06:06.550 --> 06:10.100 So we're going to need to check the coordinates. 06:11.810 --> 06:12.680 OK. 06:12.850 --> 06:22.570 So to check the coordinates is all this is going to depend on whether the Duko request has been successful 06:22.630 --> 06:23.700 or not. 06:23.710 --> 06:28.700 So if the decoder has been successful this means that the coordinates are going to be set. 06:28.870 --> 06:31.310 Otherwise they're not going to be set. 06:31.390 --> 06:36.560 So if they are not set that means that would cause an invalid departure. 06:36.700 --> 06:45.380 So we're going to say if the coordinates are not set then we can have an invalid departure departure. 06:45.970 --> 06:51.250 So it is going to the areas very well the area corresponding to involve departure 06:54.380 --> 07:04.730 OK if the assets then we go into defined variables departure latitude and departure longitude where 07:04.730 --> 07:07.040 we go into place. 07:11.100 --> 07:16.840 The elements corresponding to the lassitude of the departure and the longitude. 07:17.100 --> 07:17.700 OK. 07:18.120 --> 07:18.690 So the 07:22.900 --> 07:28.030 lassitude will correspond to the element of name departure latitude. 07:28.050 --> 07:31.890 So if you remember that's what we used. 07:31.900 --> 07:34.380 That was the name of the departure 07:39.640 --> 07:42.710 lassitude. 07:43.790 --> 07:44.890 And. 07:52.480 --> 07:53.160 OK. 07:53.260 --> 08:03.200 And how the same thing for the multitude. 08:03.350 --> 08:06.290 OK so to check if 08:09.860 --> 08:17.990 the coordinates are one of the coordinates is not set we'll just use the set function or the opposite 08:18.080 --> 08:19.830 of sets like this. 08:22.060 --> 08:31.390 So if one of them is not set we're looking at those departure lassitude. 08:32.800 --> 08:44.700 OK. 08:52.540 --> 08:53.620 Those departure 08:56.550 --> 08:59.560 longitude OK. 08:59.630 --> 09:04.170 So if one of them is not says that's me of course it involve its departure. 09:04.180 --> 09:05.180 All right. 09:06.130 --> 09:08.490 OK so we can do the same thing. 09:11.300 --> 09:12.170 With the destination 09:17.240 --> 09:21.980 we'll just change everywhere we say departure to destination 09:48.150 --> 09:51.360 OK. 09:51.420 --> 09:53.940 Now we going to check the price 09:57.920 --> 09:58.560 OK. 09:58.580 --> 09:59.980 Pretty straightforward. 10:00.020 --> 10:05.650 So we're going to check if the field is empty using the MC function. 10:08.820 --> 10:12.680 And the price was told inside the variable price. 10:13.360 --> 10:24.210 Let's see then we're going to add to the areas variable the area corresponding to missing price. 10:25.840 --> 10:30.160 Else we're going to check if the price is valid or not. 10:30.190 --> 10:33.170 So we get to use an l an ELSE IF statement. 10:33.310 --> 10:42.490 So if the price is not valid then we're going to erimus as corresponding to invalid price 10:46.150 --> 10:46.810 else 10:50.370 --> 10:59.240 if everything is OK then we are going to feel sunny size the price. 10:59.280 --> 11:01.290 OK. 11:01.290 --> 11:07.020 So for this we're going to use the filter function 11:10.740 --> 11:20.760 which will take couple of performances the price itself and filter setting size strength as we're dealing 11:20.760 --> 11:21.470 with a string 11:27.340 --> 11:28.010 OK. 11:30.690 --> 11:38.880 Now let's go back to the departure and destination if the coordinates are OK then we're going to need 11:38.880 --> 11:40.470 to feel to size 11:44.010 --> 11:46.420 the departure or the destination. 11:46.560 --> 11:47.040 OK. 11:47.320 --> 11:47.620 So 12:00.220 --> 12:01.480 that's for the departure. 12:01.680 --> 12:01.920 OK 12:05.120 --> 12:16.520 and that's for the EDITION. 12:16.720 --> 12:23.260 We don't need to feel that science has the latitude and longitude because those are just numbers and 12:23.260 --> 12:26.220 they are returned by you. 12:26.430 --> 12:26.980 All right. 12:27.100 --> 12:32.380 So now we're going to check the seats available OK. 12:32.440 --> 12:33.260 People we do. 12:33.400 --> 12:35.070 They just feel this way. 12:35.270 --> 12:41.240 So we were checking there if the price is not valid that means that there is something other than a 12:41.240 --> 12:43.590 Deja's inside the price. 12:43.660 --> 12:48.640 We're going to use the Breg much function which will take as a barometer 12:51.650 --> 12:54.110 rejects. 12:54.810 --> 12:57.900 So something other than a deejay. 12:58.040 --> 13:02.650 Going to be backslash capital-T and we have seen this before. 13:03.260 --> 13:08.730 I mean you another point I mean it's the prize itself. 13:09.030 --> 13:09.510 All right. 13:09.780 --> 13:16.840 So this copy this code and use customizes for the seats available. 13:16.890 --> 13:19.150 More or less the same thing. 13:28.360 --> 13:31.420 So if it's missing we're going to say missing 13:34.020 --> 13:34.920 seats available 13:38.810 --> 13:39.420 OK. 13:39.710 --> 13:42.380 If there is something other than a deejay it's 13:45.550 --> 13:48.600 they're going to say Invalid seats available 13:53.820 --> 13:57.070 otherwise it's going to filter. 13:57.320 --> 14:02.170 Well sanitize the variable using the fields of function. 14:03.180 --> 14:03.720 OK. 14:07.580 --> 14:09.860 Now we're going to check the frequency. 14:09.860 --> 14:13.630 So if the frequency is missing we're going to show an error message. 14:13.670 --> 14:16.460 So if empty 14:19.940 --> 14:20.690 frequency 14:23.730 --> 14:24.180 regular 14:27.660 --> 14:34.500 then we're going to add to the error message the error corresponding to missing frequency. 14:35.510 --> 14:36.490 OK. 14:36.840 --> 14:44.430 If the frequency is there then we're going to use an ELSE IF statements here to check if the frequency 14:44.430 --> 14:45.870 is really good or not. 14:46.050 --> 14:50.290 If it's regular then we're going to check if there are new days selected. 14:50.390 --> 14:51.230 OK. 14:51.600 --> 14:54.560 So if 14:57.120 --> 15:01.740 regular is equal to. 15:01.780 --> 15:02.280 Yes 15:08.300 --> 15:11.800 but it's just a quick look at the values that we placed in the 15:17.530 --> 15:19.080 case two values there. 15:19.250 --> 15:20.080 Yes. 15:20.150 --> 15:23.170 And these are the values we are looking at in the fall. 15:23.820 --> 15:24.650 OK. 15:25.960 --> 15:34.630 So if that's the case we're going to check if there are no de-selected which means that all of them 15:34.690 --> 15:36.810 are empty. 15:37.240 --> 15:43.790 Then we go into the areas variable missing. 15:43.810 --> 15:44.200 That's 15:50.100 --> 15:57.830 also we're going to check that time and if the time is missing we are going to say something similar. 15:58.130 --> 15:59.110 If MT 16:01.750 --> 16:02.160 time 16:06.840 --> 16:08.760 then we're going to say missing Tony 16:11.550 --> 16:12.820 right else 16:15.410 --> 16:17.050 meaning it's not regular 16:20.330 --> 16:23.510 then we're going to check both the date and time. 16:23.660 --> 16:24.100 OK. 16:24.320 --> 16:30.150 So if the data is missing we're going to show error message for the dates. 16:30.470 --> 16:32.960 So data is missing means empty 16:37.530 --> 16:42.860 dates and that's going to get an error message. 16:44.530 --> 16:49.610 Missing dates are going to take that time again. 16:49.800 --> 16:50.220 Right. 16:50.220 --> 16:58.710 The Ok so to check if none of these weekdays is selected. 16:58.870 --> 17:04.010 If it's regular then we're going to check if all of them are empty. 17:04.060 --> 17:05.890 So that means empty 17:08.620 --> 17:09.060 Monday 17:15.630 --> 17:16.110 and 17:26.690 --> 17:27.920 empty to day 17:36.360 --> 17:40.360 Wednesday Wednesday as day 17:47.640 --> 17:48.210 Friday 17:54.760 --> 17:55.210 it's on the 18:08.220 --> 18:10.840 OK to save. 18:11.110 --> 18:16.150 So in the next video we're going to check if there are any error messages meaning that the air is variable 18:16.320 --> 18:20.130 is not empty then we're going to print an error message in the areas. 18:20.440 --> 18:26.690 Otherwise we're going to build our query and then run the query to insert data in the database.