1 00:00:00,870 --> 00:00:08,910 In this lecture, you could create with the managing page, I called Page because we will be creating 2 00:00:08,910 --> 00:00:17,010 two pages and managed page initial results page inside the manage page, we will create a forum for 3 00:00:17,010 --> 00:00:24,270 inserting a comment to a database, and we will create a text area for shoving the result of the comments. 4 00:00:25,370 --> 00:00:33,890 The managed page will send get requests to the show results page in every two seconds in order to retrieve 5 00:00:33,890 --> 00:00:35,480 results from the database. 6 00:00:36,880 --> 00:00:44,590 To do so, we will be using forms and text area type of e-mail to create visual objects and we will 7 00:00:44,590 --> 00:00:52,270 be using the example HTTP request class and set time of the function of JavaScript in order to send 8 00:00:52,270 --> 00:00:54,480 that request in two seconds in trouble. 9 00:00:55,630 --> 00:01:02,020 If you are new to discuss and police learn more about specified keywords before keeping continue. 10 00:01:02,380 --> 00:01:04,300 So let's start calling. 11 00:01:06,560 --> 00:01:09,740 Open your 8:00 editor and create a new file. 12 00:01:12,240 --> 00:01:14,070 It will be managed at BHP. 13 00:01:16,410 --> 00:01:26,130 This page will be authenticated, users only soberness include our station that each page here and also 14 00:01:26,610 --> 00:01:29,250 since we will be sending Curie's. 15 00:01:29,970 --> 00:01:33,930 We need to include that file. 16 00:01:37,070 --> 00:01:42,470 And now open your browser and go to your index page. 17 00:01:44,820 --> 00:01:45,900 Log in first. 18 00:01:50,190 --> 00:01:55,380 If your index page is broken like this, you can fix it by. 19 00:01:58,280 --> 00:02:09,470 Adding to our tag just before the eco functions and close the theater just after the eco functions, 20 00:02:11,660 --> 00:02:15,290 now refresh your page and we are ready. 21 00:02:16,130 --> 00:02:25,250 When a user clicks, diminishing user will be redirected to manage that page with a guide parameter 22 00:02:25,370 --> 00:02:26,360 called What? 23 00:02:27,080 --> 00:02:31,900 We will be using this parameter in order to execute our queries. 24 00:02:33,080 --> 00:02:35,780 So let's create our first form. 25 00:02:39,890 --> 00:02:47,090 To do so, we will be using phone tag and reform will have two attributes, first, attribute to the 26 00:02:47,090 --> 00:02:55,840 action plan because we will send to get we will send the request to the same page and our method will 27 00:02:55,840 --> 00:03:04,610 be passed or a form will have to input fields first into the field filled with the commands and type 28 00:03:04,610 --> 00:03:05,210 of text. 29 00:03:05,900 --> 00:03:11,570 Its names command and its placeholder is command. 30 00:03:13,190 --> 00:03:21,530 And second input field will be the will be a hidden field actually, because it will be equal to the 31 00:03:21,830 --> 00:03:25,240 value of the parameter inside get requests. 32 00:03:25,370 --> 00:03:27,880 So we don't we do not need to see this. 33 00:03:28,690 --> 00:03:39,150 This type that's created its type will be hidden, its name will be bought and its value will be equals 34 00:03:39,170 --> 00:03:42,560 to get parameters value. 35 00:03:46,120 --> 00:03:53,400 And let's print out the value of the parameter inside to get fixed by using a one line script. 36 00:03:57,240 --> 00:04:06,400 Yep, we are ready and we need the input, we need the submit button in order to send all post requests, 37 00:04:07,100 --> 00:04:10,190 so let's created the type to submit. 38 00:04:10,940 --> 00:04:16,310 The name will be submitted and we want to fill the self-command 39 00:04:18,830 --> 00:04:20,150 and close your format. 40 00:04:20,260 --> 00:04:24,930 And let's refresh to Page and see if everything went well. 41 00:04:25,500 --> 00:04:25,840 Yep. 42 00:04:26,000 --> 00:04:28,220 As you can see, our forum is here. 43 00:04:29,520 --> 00:04:38,520 And actually, you can check the hidden inputs by weaving the page source, as you can see, or hidden. 44 00:04:40,090 --> 00:04:40,960 Field this year. 45 00:04:43,760 --> 00:04:50,330 So let's process that request by creating a script. 46 00:04:52,150 --> 00:05:00,730 To your go inside your tank and create an if statement if the given request is post. 47 00:05:05,770 --> 00:05:08,680 And if it has 48 00:05:13,120 --> 00:05:14,530 command and 49 00:05:17,770 --> 00:05:23,620 parameters, we will execute a database security. 50 00:05:28,350 --> 00:05:34,480 So we need to create a prepared statement in order to execute on this category, let's create it. 51 00:05:35,070 --> 00:05:45,060 I will call it said command and it will be prepared to update victims. 52 00:05:45,300 --> 00:05:47,940 Said Command is equal. 53 00:05:48,120 --> 00:05:50,340 Question mark where post name. 54 00:05:50,910 --> 00:05:51,720 Question mark. 55 00:05:53,810 --> 00:05:59,890 Replace the first question mark with. 56 00:06:02,560 --> 00:06:08,920 Command and second question mark will be replaced with the parameter. 57 00:06:13,430 --> 00:06:19,360 And execute security by using execute function 58 00:06:22,310 --> 00:06:27,770 and let's test or court, open your terminal and connect your database, 59 00:06:30,900 --> 00:06:31,910 as you can see. 60 00:06:32,750 --> 00:06:36,110 No comment has been inserted the database. 61 00:06:36,860 --> 00:06:42,440 And let's try to insert a comment by using all form I would call test command. 62 00:06:43,040 --> 00:06:52,150 The test command will be inserted to the hostname A, which is specified in the parameter in the request 63 00:06:52,940 --> 00:06:54,050 and let's test it. 64 00:06:56,180 --> 00:06:59,420 As you can see, command has been inserted. 65 00:06:59,990 --> 00:07:01,070 So it's working. 66 00:07:02,030 --> 00:07:02,990 What's next? 67 00:07:03,890 --> 00:07:07,400 We need to create the text area for showing the results. 68 00:07:08,570 --> 00:07:11,480 To do so, kindly use text. 69 00:07:11,480 --> 00:07:17,660 Every attack and all text area tag will have an attribute which will be ID. 70 00:07:18,380 --> 00:07:27,110 We will be using this ID in order to update data inside the text area and it will be a result area. 71 00:07:29,040 --> 00:07:35,600 You can also use column and roll attributes in order to make your text area bigger or smaller. 72 00:07:35,600 --> 00:07:41,390 But actually it's not necessary because you can already expand it like this. 73 00:07:45,300 --> 00:07:52,290 So what's next, we need to create another page in order to receive the result of the. 74 00:07:55,660 --> 00:08:00,100 Let's create a page called Show Results that BHP. 75 00:08:04,730 --> 00:08:12,050 This page will also be authenticated users only, so that's include the that people. 76 00:08:14,120 --> 00:08:22,310 And also we need to include that people file because we will be sending as clear requests as Curie's. 77 00:08:25,790 --> 00:08:34,910 Inside the managed page, we will send get requests to the results, show results, page in every two 78 00:08:34,910 --> 00:08:38,540 seconds to check possible results. 79 00:08:39,230 --> 00:08:47,690 And if any result has been set, we will show the results by using JavaScript functions inside the text 80 00:08:47,690 --> 00:08:48,080 area. 81 00:08:51,080 --> 00:09:03,890 So let's let's create or show results first, if the given request method is get this time. 82 00:09:07,450 --> 00:09:14,050 And if he tests what parameter? 83 00:09:17,420 --> 00:09:22,040 We will try to retrieve the comment results from the database. 84 00:09:23,420 --> 00:09:26,570 Let's create a prepared statement and I will call it. 85 00:09:28,760 --> 00:09:41,150 Retrieve results and it will be satellite combined results from victims were. 86 00:09:41,950 --> 00:09:50,360 Of course, the question mark, and that's the place that hostname that question mark with the parameter 87 00:09:51,080 --> 00:09:53,690 by using the buying matter. 88 00:09:55,550 --> 00:10:03,350 As for string, because the data type of parameter in the string, and that's replace the question mark 89 00:10:03,360 --> 00:10:04,580 with the board parameter. 90 00:10:07,000 --> 00:10:08,590 And execute security. 91 00:10:10,720 --> 00:10:12,550 By using executed function. 92 00:10:14,460 --> 00:10:26,640 In order to store results, we need to use store result function and in order to assign assign the. 93 00:10:30,360 --> 00:10:39,750 Turnover of security to a local variable we need to use to find is old function. 94 00:10:40,730 --> 00:10:45,800 And I will be signing the return value of security to a variable called. 95 00:10:49,060 --> 00:11:00,190 Command results and the need to use fetch function in order to complete our query, and then we can 96 00:11:00,190 --> 00:11:10,000 return the result of the cure, we can we can return the command result by using equal function and 97 00:11:10,060 --> 00:11:10,780 we are ready. 98 00:11:14,210 --> 00:11:15,410 Let's test your code. 99 00:11:16,870 --> 00:11:26,920 Called your show results be they get parameter called what a as you can see, a test result has been 100 00:11:26,920 --> 00:11:27,500 returned. 101 00:11:28,810 --> 00:11:35,590 So we need to we need to send a get request inside to manage that page. 102 00:11:36,660 --> 00:11:39,810 To get this result from the shock results page. 103 00:11:42,170 --> 00:11:52,450 To do so, open your cable skip tag, which is create and create a function by using function keywords, 104 00:11:53,330 --> 00:11:55,430 I will call it frequently results. 105 00:12:00,050 --> 00:12:08,750 In order to send a request to JavaScript, we will be using the example HTP to request class, so we 106 00:12:08,750 --> 00:12:13,980 need to create an instance of it to do so, create a variable called example. 107 00:12:14,000 --> 00:12:14,450 Right. 108 00:12:15,320 --> 00:12:21,560 And it will be cool to new example, HTTP request. 109 00:12:25,760 --> 00:12:33,290 We also need a variable for the euro, so let's create it all, the euro will be show results that could 110 00:12:33,320 --> 00:12:43,740 be questionmark parameter and it will be equal to the value of the both parameter that to get requests. 111 00:12:44,390 --> 00:12:51,350 So we need to use the P in order to print out the value of the bond parameter. 112 00:12:51,440 --> 00:12:52,520 Instead, we get request. 113 00:12:53,720 --> 00:12:54,310 Let's do it. 114 00:13:00,900 --> 00:13:11,420 And we are done here now, we can create a get request by using open method of the examination to first 115 00:13:11,430 --> 00:13:11,920 class. 116 00:13:12,990 --> 00:13:14,730 It takes three parameters. 117 00:13:14,820 --> 00:13:21,540 The first parameter will be the method of the request, which we'll get and second parameter is your 118 00:13:21,540 --> 00:13:21,920 URL. 119 00:13:22,560 --> 00:13:24,360 And third parameter is false. 120 00:13:25,010 --> 00:13:28,720 You can learn more about them by reading their official descriptions. 121 00:13:28,980 --> 00:13:30,360 So just use it for now. 122 00:13:31,230 --> 00:13:41,700 And then we can send a get request by using scent method of the example HTP Brookhurst class and takes 123 00:13:41,700 --> 00:13:46,770 one argument and it will be now because they are using that method. 124 00:13:51,780 --> 00:14:00,660 And what's next, we need to execute this function in every two seconds to do so, we will use a time 125 00:14:00,660 --> 00:14:01,350 out method. 126 00:14:01,950 --> 00:14:03,540 It takes two arguments. 127 00:14:03,870 --> 00:14:08,020 First arguments is the function name will be executed. 128 00:14:09,990 --> 00:14:17,340 And second argument is time interval, which will be two thousand milliseconds. 129 00:14:19,510 --> 00:14:20,170 And. 130 00:14:21,540 --> 00:14:31,260 If the if the result of ticket requests responsive to get requests is. 131 00:14:34,260 --> 00:14:35,940 More than two characters. 132 00:14:36,830 --> 00:14:44,490 It is the result of the request has more than two characters, people showed the common result is that 133 00:14:44,490 --> 00:14:49,550 the the area to do so, let's create any statements in 134 00:14:52,910 --> 00:14:53,460 response. 135 00:14:53,480 --> 00:15:01,760 Text of the get requests has lines longer than two characters. 136 00:15:03,770 --> 00:15:13,130 We will show the the result is that the text area by using document objects of JavaScript documents. 137 00:15:15,560 --> 00:15:16,980 Yeah, elements. 138 00:15:19,910 --> 00:15:29,900 My ID and our IDs result area and by using my property. 139 00:15:31,570 --> 00:15:32,470 We can set. 140 00:15:33,980 --> 00:15:43,940 The text inside the text area, so text will be called to examine the wreck that responds to text attribute 141 00:15:43,940 --> 00:15:48,320 of the instance of the example pudding first class. 142 00:15:52,940 --> 00:15:57,230 And we will exit the function by using the term keyword 143 00:16:00,140 --> 00:16:07,430 and call your function inside the script tag. 144 00:16:08,350 --> 00:16:10,480 And seems like we are ready. 145 00:16:11,260 --> 00:16:20,560 So let's test Allcott, refresh your page, and as you can see, the test result has been shown in text 146 00:16:20,560 --> 00:16:22,990 area where we send the command. 147 00:16:23,400 --> 00:16:25,510 The results will be shown here. 148 00:16:26,780 --> 00:16:29,950 So that's it for this lecture series. 149 00:16:30,030 --> 00:16:30,650 The next one.