So let's modify the form just enough that we'll be able to test our database function to insert a reservation.
So let's go look at the form right now.
We just have first name, last name, email and phone, and we need to add some things.
And what we need to add our first name, last name, email, phone.
We need start date and date room ID and that's all we need to add.
Everything else is taking care of us.
And this is something we're not using, but we might at some point in the future.
So we need to add start date and date and remedy what we can do that will go over to our template,
which is under templates and we'll find make a reservation page.
There it is.
All right.
Let's just put a couple of fields in here just for the sake of making this work.
So what I'll do and it doesn't even matter what they look like at this point, we'll just say div we'll
put them below the first name and last name just for just we'll put them in here for now.
It doesn't matter where they go, we'll clean this up later.
Div class equals form group
and then a label label four equals start date and start date and then an input.
Type equals text, name equals start date, ID equals start date and class equals form control.
All right, copy this.
And I'll paste it, then I'll change it to end date.
And then we need a remedy, and I'll just do that as a hidden field input type equals hidden name equals
room ID value equals one, and we don't have a value equals one in the database yet.
So we have to add that in a moment.
But let's make sure that our form looks right.
OK, we've got to run the application.
And there it goes and a fantastic on my computer for some reason, I apologize for that.
Hopefully it will stop soon.
It is running and we have a start date and an end date so we can populate that.
And our hidden field should be right between these two.
So we're good to go.
So we have that now.
We need to put something in our room table.
So wrong application this one, and I'll connect to my local host and I'll go to my bookings and I'll
find rooms and it's currently empty.
So let's adoro and I'll call this one Generals' Quarters and put it in a date here and here.
And if I save this, I now have.
I now have an entry in my database perfect, so I should be able now to fill this out with valid data.
ABC C start date 2020, say eleven thirty to twenty twenty 12 02.
My email is me here dossier and my phone is five or six.
Five or six or six or six.
Six, six, six six.
And hopefully this will work and it does.
OK, now let's go look at our database and check the reservations table and there is everything that
I need.
Perfect.
So we can add some information to the database.
Now, that's only one step if you think it through.
When we go back to our code here, to our handlers after we insert the reservation, we need to do one
more thing before we can redirect them.
We need to insert the reservation restrictions.
So we need to go to the room restrictions table, which would be right here.
And it requires some things.
It requires the start date.
I have that.
It requires the end date.
I have that.
It requires the room ID.
I have that.
I don't have the reservation ID.
I know what the restriction ID is going to be, but I have to populate some entries in the table before
I can do that.
And these two are no problem.
But this one, the reservation ID I don't have and I don't have it because in my database routine which
is under the postgres don't go.
All this gives me back is an error.
So I need to modify this to actually return the ID of the newly inserted reservation.
Now if you're familiar with something like MySQL or Maria DB, you know that you have access to a function
called Last Insert ID and that's really easy.
You can just call the function.
What's the last insert ID and the connection will hand it back to you.
And then you have the ID of the inserted record.
Postgrads doesn't have that, but PostgreSQL does have something called returning.
So I can say returning ID, but that means I need to change the way that I'm making the query from an
execute to something else.
So we'll take care of that in the next lecture.