In this lecture, you could create with the managing page, I called Page because we will be creating
two pages and managed page initial results page inside the manage page, we will create a forum for
inserting a comment to a database, and we will create a text area for shoving the result of the comments.
The managed page will send get requests to the show results page in every two seconds in order to retrieve
results from the database.
To do so, we will be using forms and text area type of e-mail to create visual objects and we will
be using the example HTTP request class and set time of the function of JavaScript in order to send
that request in two seconds in trouble.
If you are new to discuss and police learn more about specified keywords before keeping continue.
So let's start calling.
Open your 8:00 editor and create a new file.
It will be managed at BHP.
This page will be authenticated, users only soberness include our station that each page here and also
since we will be sending Curie's.
We need to include that file.
And now open your browser and go to your index page.
Log in first.
If your index page is broken like this, you can fix it by.
Adding to our tag just before the eco functions and close the theater just after the eco functions,
now refresh your page and we are ready.
When a user clicks, diminishing user will be redirected to manage that page with a guide parameter
called What?
We will be using this parameter in order to execute our queries.
So let's create our first form.
To do so, we will be using phone tag and reform will have two attributes, first, attribute to the
action plan because we will send to get we will send the request to the same page and our method will
be passed or a form will have to input fields first into the field filled with the commands and type
of text.
Its names command and its placeholder is command.
And second input field will be the will be a hidden field actually, because it will be equal to the
value of the parameter inside get requests.
So we don't we do not need to see this.
This type that's created its type will be hidden, its name will be bought and its value will be equals
to get parameters value.
And let's print out the value of the parameter inside to get fixed by using a one line script.
Yep, we are ready and we need the input, we need the submit button in order to send all post requests,
so let's created the type to submit.
The name will be submitted and we want to fill the self-command
and close your format.
And let's refresh to Page and see if everything went well.
Yep.
As you can see, our forum is here.
And actually, you can check the hidden inputs by weaving the page source, as you can see, or hidden.
Field this year.
So let's process that request by creating a script.
To your go inside your tank and create an if statement if the given request is post.
And if it has
command and
parameters, we will execute a database security.
So we need to create a prepared statement in order to execute on this category, let's create it.
I will call it said command and it will be prepared to update victims.
Said Command is equal.
Question mark where post name.
Question mark.
Replace the first question mark with.
Command and second question mark will be replaced with the parameter.
And execute security by using execute function
and let's test or court, open your terminal and connect your database,
as you can see.
No comment has been inserted the database.
And let's try to insert a comment by using all form I would call test command.
The test command will be inserted to the hostname A, which is specified in the parameter in the request
and let's test it.
As you can see, command has been inserted.
So it's working.
What's next?
We need to create the text area for showing the results.
To do so, kindly use text.
Every attack and all text area tag will have an attribute which will be ID.
We will be using this ID in order to update data inside the text area and it will be a result area.
You can also use column and roll attributes in order to make your text area bigger or smaller.
But actually it's not necessary because you can already expand it like this.
So what's next, we need to create another page in order to receive the result of the.
Let's create a page called Show Results that BHP.
This page will also be authenticated users only, so that's include the that people.
And also we need to include that people file because we will be sending as clear requests as Curie's.
Inside the managed page, we will send get requests to the results, show results, page in every two
seconds to check possible results.
And if any result has been set, we will show the results by using JavaScript functions inside the text
area.
So let's let's create or show results first, if the given request method is get this time.
And if he tests what parameter?
We will try to retrieve the comment results from the database.
Let's create a prepared statement and I will call it.
Retrieve results and it will be satellite combined results from victims were.
Of course, the question mark, and that's the place that hostname that question mark with the parameter
by using the buying matter.
As for string, because the data type of parameter in the string, and that's replace the question mark
with the board parameter.
And execute security.
By using executed function.
In order to store results, we need to use store result function and in order to assign assign the.
Turnover of security to a local variable we need to use to find is old function.
And I will be signing the return value of security to a variable called.
Command results and the need to use fetch function in order to complete our query, and then we can
return the result of the cure, we can we can return the command result by using equal function and
we are ready.
Let's test your code.
Called your show results be they get parameter called what a as you can see, a test result has been
returned.
So we need to we need to send a get request inside to manage that page.
To get this result from the shock results page.
To do so, open your cable skip tag, which is create and create a function by using function keywords,
I will call it frequently results.
In order to send a request to JavaScript, we will be using the example HTP to request class, so we
need to create an instance of it to do so, create a variable called example.
Right.
And it will be cool to new example, HTTP request.
We also need a variable for the euro, so let's create it all, the euro will be show results that could
be questionmark parameter and it will be equal to the value of the both parameter that to get requests.
So we need to use the P in order to print out the value of the bond parameter.
Instead, we get request.
Let's do it.
And we are done here now, we can create a get request by using open method of the examination to first
class.
It takes three parameters.
The first parameter will be the method of the request, which we'll get and second parameter is your
URL.
And third parameter is false.
You can learn more about them by reading their official descriptions.
So just use it for now.
And then we can send a get request by using scent method of the example HTP Brookhurst class and takes
one argument and it will be now because they are using that method.
And what's next, we need to execute this function in every two seconds to do so, we will use a time
out method.
It takes two arguments.
First arguments is the function name will be executed.
And second argument is time interval, which will be two thousand milliseconds.
And.
If the if the result of ticket requests responsive to get requests is.
More than two characters.
It is the result of the request has more than two characters, people showed the common result is that
the the area to do so, let's create any statements in
response.
Text of the get requests has lines longer than two characters.
We will show the the result is that the text area by using document objects of JavaScript documents.
Yeah, elements.
My ID and our IDs result area and by using my property.
We can set.
The text inside the text area, so text will be called to examine the wreck that responds to text attribute
of the instance of the example pudding first class.
And we will exit the function by using the term keyword
and call your function inside the script tag.
And seems like we are ready.
So let's test Allcott, refresh your page, and as you can see, the test result has been shown in text
area where we send the command.
The results will be shown here.
So that's it for this lecture series.
The next one.