Now we know that esky Well we need to insert the data from the farm into the database.
We can use this code here in our new article page.
We've already got code in article that psap here to execute and ask you our statement.
So that start by copying that
and pasting it here
replacing the avad Dump line in our new article script will change the ESC you l from a select to an
insert into the article table.
We want the value in the idae column to be assigned after magically So we'll add to the list of columns
and emett the I.D. column.
Next we'll add the list of values.
And for now let's just concatenate the values in the post array directly into the Eskew L string making
sure we surround each value in single quotes and that we separate them with commas.
And at the end we have a closing bracket before we continue let's check the ESC u l string that we're
creating here by dumping it out and exiting the script.
Then in the browser if we add some values to the farm and submit it.
This is the esky Well statement that we're going to execute.
That looks good so we can continue with our code.
We can delete this line now and next will execute the ESC u l using the my ESC You will I query function
here and that's before.
If the results are false we'll print out the error next though we're not selecting data so we don't
want to use this function.
Instead let's skip the I.D. of the new word inserted rijkaard this I.D. will be assigned automatically
by the database server.
We can get this using the my esky Well I insert idae function which returns the automatically generated
idae used in the insert query so that call this function passing in the database connection variable.
For now lets just print out this value like that.
One more thing we need to do is include the code that connects to the database which is this required
line here.
So will copy that
and in our new article script.
It here
before we create our Eskew L statement.
Let's give that a try.
If we add some values into the form inputs and then submit the farm we get the message.
Telling us the idea of the rijkaard that's been inserted.
If we look at the database Here's the new rijkaard and it's eidy corresponds to the value we got from
my esky Well I insert idees function.
So now we can see this record on our index page and on the individual article page like that.
When we inserted this rijkaard we made sure that all the fields had valid data in for example the date
time value here needs to be specified like this year dash month dash day and so on.
At the moment we get an error.
If we didn't specify this value with this farmer at all if we admitted it all together for now we'll
make sure we enter valid data into the farm and will look at how to validate this data shortly.