WEBVTT 00:00:07.380 --> 00:00:11.660 Now what are we going to do if there are no errors. 00:00:11.660 --> 00:00:16.080 OK. 00:00:19.460 --> 00:00:23.490 So if there are errors we print the error message. 00:00:23.490 --> 00:00:30.410 Now if there are no errors we are going to go for else. 00:00:31.000 --> 00:00:34.290 OK. 00:00:37.920 --> 00:00:40.370 And we are going to send our e-mail. 00:00:40.710 --> 00:00:44.500 OK so now that we have no errors so we're going to send our e-mail. 00:00:44.580 --> 00:00:46.010 OK. 00:00:46.290 --> 00:00:47.520 So first let's define 00:00:51.690 --> 00:00:57.060 the variables or the arguments of the mail function. 00:00:57.510 --> 00:01:00.150 OK so we're going to define the message 00:01:05.220 --> 00:01:10.770 the receiver of the e-mail. 00:01:11.690 --> 00:01:18.900 And to said that to a certain value and we are going to define the 00:01:24.160 --> 00:01:29.580 Suko the receiver the message the subject as well. 00:01:31.050 --> 00:01:32.100 OK. 00:01:32.850 --> 00:01:40.660 And if you want to send an e-mail e-mail we are going to add a head is variable. 00:01:42.140 --> 00:01:42.640 OK. 00:01:42.960 --> 00:01:55.420 So I'm going to send the email to this address. 00:02:01.730 --> 00:02:03.520 OK. 00:02:03.820 --> 00:02:11.980 And the subjects he's going to be for example contact 00:02:14.820 --> 00:02:17.860 and the message. 00:02:18.690 --> 00:02:22.920 Let's have. 00:02:25.630 --> 00:02:28.740 OK let's have a paragraph 00:02:34.640 --> 00:02:40.990 and then we're going to have the name of the user. 00:02:41.250 --> 00:02:46.780 And then another paragraph we're going to say the e-mail of the user. 00:02:47.550 --> 00:02:52.950 And then another paragraph we're going to say a message for example and then a final point of the paragraph 00:02:52.950 --> 00:02:55.110 where we're going to write the actual message 00:02:58.080 --> 00:02:58.760 of the user. 00:02:58.950 --> 00:03:04.780 OK so I'm going to write to the beginning name. 00:03:07.360 --> 00:03:15.890 In the name of the user and then e-mail 00:03:18.810 --> 00:03:19.900 all the email 00:03:23.740 --> 00:03:25.380 and then message 00:03:30.400 --> 00:03:39.690 them then the last paragraph we can have the message of the user and let's places inside strong tags 00:03:39.690 --> 00:03:42.280 so that it's it's bold. 00:03:42.470 --> 00:03:45.590 OK. 00:03:47.270 --> 00:03:50.300 And we want the message of the user. 00:03:50.780 --> 00:03:51.050 OK. 00:03:51.060 --> 00:03:52.990 So that's going to be our e-mail. 00:03:53.010 --> 00:04:00.060 And since it's an HMO e-mail we're going to add a fourth argument which is going to be the head is going 00:04:00.060 --> 00:04:01.310 to say that to 00:04:04.370 --> 00:04:05.120 contents 00:04:08.070 --> 00:04:11.340 they may be missing something. 00:04:11.350 --> 00:04:20.040 OK we need to close the those codes that we're going to send this to Content-Type and are going to say 00:04:20.070 --> 00:04:23.710 that to text for Slash HMO. 00:04:24.400 --> 00:04:25.540 OK. 00:04:25.770 --> 00:04:28.760 All right so now we are ready to send our e-mail. 00:04:29.460 --> 00:04:30.960 OK. 00:04:31.350 --> 00:04:39.060 So so rather than just saying mail and then putting all the arguments there we are going to check if 00:04:39.090 --> 00:04:41.140 the e-mail has been sent. 00:04:41.340 --> 00:04:45.770 OK since the mail function is going to return a boolean. 00:04:46.050 --> 00:04:53.780 So we're going to check if mail and then replace all our promises the two subjects 00:04:57.000 --> 00:04:57.660 message 00:05:00.360 --> 00:05:04.710 and hadis pay. 00:05:04.740 --> 00:05:12.870 So if the e-mail has been accepted successfully for delivery then 00:05:18.490 --> 00:05:26.560 we are going to set the results message to a success. 00:05:26.560 --> 00:05:35.590 Dave OK so it's going to be a day of class alerts and success. 00:05:36.250 --> 00:05:36.400 OK 00:05:39.570 --> 00:05:43.630 let's keep it close. 00:05:43.630 --> 00:05:47.550 Let's let success. 00:05:48.730 --> 00:05:49.330 OK. 00:05:49.460 --> 00:05:57.850 Now let's write some text saying for example Thanks for your message. 00:05:58.030 --> 00:06:06.270 We will get back to you as soon as possible. 00:06:10.620 --> 00:06:11.380 OK. 00:06:11.950 --> 00:06:15.520 So that's if the e-mail has been sent successfully. 00:06:16.180 --> 00:06:17.080 If not. 00:06:17.440 --> 00:06:19.410 We're going to go for else. 00:06:19.910 --> 00:06:23.760 And this time we are going to choose another value for our results message. 00:06:23.920 --> 00:06:25.850 So it's going to be a warning message. 00:06:26.110 --> 00:06:27.620 OK. 00:06:27.820 --> 00:06:36.220 And rather than using an alert sex says we're going to use alerts warning and you're going to say for 00:06:36.220 --> 00:06:36.880 example 00:06:41.650 --> 00:06:46.660 unable to send e-mail. 00:06:46.660 --> 00:06:51.600 Please try again later for example. 00:06:52.180 --> 00:06:56.120 OK. 00:06:56.230 --> 00:07:01.790 And anyway at the end we are echoing our results message. 00:07:01.810 --> 00:07:04.940 OK so of course our carriage ready. 00:07:04.990 --> 00:07:10.320 We'll see in a bit how we're going to redirect the user to the other page. 00:07:10.390 --> 00:07:14.210 But for now we want to print result's message in all cases. 00:07:14.350 --> 00:07:14.870 OK. 00:07:14.980 --> 00:07:22.060 So this Troy safe refresh to page just is from the beginning. 00:07:22.060 --> 00:07:24.410 So let's write something that 00:07:28.020 --> 00:07:29.260 OK. 00:07:29.410 --> 00:07:31.740 Let's play some message. 00:07:31.750 --> 00:07:33.370 So if I click on send message 00:07:37.120 --> 00:07:38.890 it says thanks for your message. 00:07:39.040 --> 00:07:45.850 We will get back to you as soon as possible so this means that the e-mail has been sent successfully 00:07:45.870 --> 00:07:46.030 . 00:07:46.180 --> 00:07:47.230 OK. 00:07:47.230 --> 00:07:51.170 So we had no errors. 00:07:52.090 --> 00:08:01.870 Ok so in the code we went through the stage where we were able to send an email and the e-mail has been 00:08:01.870 --> 00:08:03.090 sent successfully. 00:08:03.430 --> 00:08:05.800 OK so let's check in our inbox. 00:08:06.070 --> 00:08:07.450 If you received any e-mail 00:08:10.330 --> 00:08:13.500 and you can see the day of calls and e-mail they it click there 00:08:16.350 --> 00:08:24.400 and the message is high and we can see that we have an e-mail message and we can see that the text is 00:08:24.460 --> 00:08:25.420 valid. 00:08:25.990 --> 00:08:27.040 OK. 00:08:27.040 --> 00:08:36.440 So that's how we can create a nice simple responsive contacts form using BHB and bootstrap. 00:08:36.460 --> 00:08:38.500 So now one final change. 00:08:38.530 --> 00:08:45.430 So rather than printing the success message here when we send the e-mail we are going to redirect the 00:08:45.490 --> 00:08:51.450 user to another page which is going to be the thanks for your message page. 00:08:51.480 --> 00:08:52.070 OK. 00:08:52.330 --> 00:08:54.790 So let's copy the templates 00:08:59.230 --> 00:09:00.760 to this new file. 00:09:01.100 --> 00:09:08.780 Anti-New the title to things for your message. 00:09:10.240 --> 00:09:10.930 OK. 00:09:11.230 --> 00:09:23.770 So we're just going to go to the Casina Dave or let's go to the contact form Dave and get rid of the 00:09:23.770 --> 00:09:24.600 contents. 00:09:24.730 --> 00:09:28.910 Now. 00:09:32.860 --> 00:09:37.270 OK. 00:09:37.270 --> 00:09:40.090 So let's have to say Hedding 00:09:44.050 --> 00:09:51.050 saying thanks and let's have a Dave after that. 00:09:51.880 --> 00:09:56.590 I think thanks for your message. 00:09:56.650 --> 00:10:00.370 We will get back to you as soon as possible 00:10:02.910 --> 00:10:04.980 . 00:10:05.690 --> 00:10:13.280 Now let's give you say clus alerts alerts success. 00:10:15.030 --> 00:10:15.360 OK 00:10:20.290 --> 00:10:21.420 OK. 00:10:21.640 --> 00:10:22.780 We're going to rename this. 00:10:22.840 --> 00:10:27.160 Let's just keep the same class for the contacts for. 00:10:27.370 --> 00:10:29.500 You can rename it if you want to anyway. 00:10:29.560 --> 00:10:34.260 So that's our thank you page. 00:10:34.630 --> 00:10:42.420 So now rather than printing the results message. 00:10:43.350 --> 00:10:44.340 OK. 00:10:44.890 --> 00:10:49.690 We are going to redirect to use that to this page. 00:10:49.690 --> 00:10:53.580 So how are we going to do that's SAVVIDES comments. 00:10:53.590 --> 00:10:56.230 This piece of code. 00:10:56.260 --> 00:10:59.260 So rather than setting the results message to this value. 00:10:59.470 --> 00:11:00.710 So it is going to come in. 00:11:01.080 --> 00:11:05.410 And rather than having that we are going to 00:11:10.270 --> 00:11:13.240 use a function called header. 00:11:13.800 --> 00:11:14.600 OK. 00:11:14.980 --> 00:11:19.820 So if you click on control k you can see details about this function. 00:11:20.170 --> 00:11:26.390 So it will just it's saying here send a row header. 00:11:27.010 --> 00:11:35.870 And what this function is doing is just that it will just redirects us to a new location. 00:11:35.890 --> 00:11:46.810 So in the parameter we are just going to writes a drink and say the double quotes we're going to write 00:11:46.870 --> 00:11:52.250 location and we're going to say where we want to be had it. 00:11:52.270 --> 00:11:52.720 OK. 00:11:52.900 --> 00:11:59.270 So we are going to go to the file called 20 Daut. 00:11:59.470 --> 00:12:03.400 Thanks for your message. 00:12:03.400 --> 00:12:04.840 Those BHB. 00:12:06.270 --> 00:12:07.680 OK. 00:12:08.110 --> 00:12:10.450 And rather than echoing the results message 00:12:16.180 --> 00:12:17.130 here. 00:12:17.420 --> 00:12:17.850 OK. 00:12:17.920 --> 00:12:23.800 Well we can we can keep it's actually yeah we can keep it here because all the other cases are going 00:12:23.800 --> 00:12:27.770 to need to print the results message from from there. 00:12:27.980 --> 00:12:30.490 OK so now let's test this. 00:12:30.790 --> 00:12:39.700 OK so if I save this drug it from the beginning again. 00:12:39.700 --> 00:12:47.910 So now let's feel the right message. 00:12:47.920 --> 00:12:57.400 So if we click on send message now we can see that we have been redirected to the thank you page. 00:12:57.400 --> 00:12:58.120 OK. 00:12:58.560 --> 00:13:05.750 And we can also check if you received another e-mail. 00:13:05.800 --> 00:13:07.530 Click on e-books. 00:13:07.570 --> 00:13:11.380 Not yet. 00:13:11.380 --> 00:13:12.010 Let's try again 00:13:12.030 --> 00:13:21.340 . 00:13:21.340 --> 00:13:24.950 You know it and we can see the e-mail that. 00:13:25.230 --> 00:13:25.910 OK. 00:13:26.170 --> 00:13:29.260 So the e-mail has been sent successfully. 00:13:29.260 --> 00:13:30.320 All right. 00:13:30.910 --> 00:13:39.250 So that's how we can create a nice simple Contacts form using BHB and bootstrap. 00:13:39.760 --> 00:13:40.730 OK. 00:13:40.810 --> 00:13:45.430 In the next video we're going to cover a date and time in BHB