Jump to content

Success page for cinema ticket booking system


Go to solution Solved by Barand,

Recommended Posts

Hi Guys,

I am creating a cinema booking system, all is well, just one thing left to do - a booking confirmation after seats are booked. I can get the page redirecting in Javascript and this is not the problem. In my mind I was thinking of getting the last lastInsertId() from the booking table, pass that to the success page, write some sql and be done with it. But my booking table looks like this:
 

booking

booking_id         seat_id       screening_id

57                       399                   2
58                      400                    2 
59                      751                    96
60                      752                    96

So there are multiple lastinsertId

Now, I was doing a hotel booking system before, so I just got the last id, which could have 1 or more rooms attached to the id and then I could do my sql for the confirm page.

This is different - there can be 1, 2, 3 or more tickets. And as you can see above each record has a booking_id - which makes sense because it identifies a single ticket each time. But how do I go about this confirm page? Do I write some code to pull the latest booked tickets, say someone logs on and books 3 tickets - do I remember that 3 tickets were booked, get there booking_id and go from there? But how would I know how many tickets the user just booked? I could do it by screening_id, but in between the transaction someone else could have booked tickets for the same screening.

Any advice/logic would be welcome

Thanks

 

 

Edited by webdeveloper123
Link to comment
Share on other sites

If they book several seats you will have several booking_ids.

What will you do with them when you have them?

The reason for getting the last insert id is to use it as a foreign key when you post child records (eg write invoice header then invoice item records). From your data model this isn't the case.

Link to comment
Share on other sites

17 minutes ago, Barand said:

What will you do with them when you have them?

 

Build a confirmation page like "Booking successful" Here are your booking details:
Wonka
Monday 26th Feb
19.00
Screen 5
Seat Numbers: C-1, C-2, C-3
Price: £24.66

Edited by webdeveloper123
Link to comment
Share on other sites

37 minutes ago, webdeveloper123 said:

This is different

not really. you are doing the same operation, only the name/meaning of the data is different.

you should have a booking/reservation/order table, that holds the unique/one-time booking data. a single row is inserted into this table when someone submits an order. this row produces a booking id (the autoincrement primary index.) you would use this booking id to store the related booking item data, one row per item, which in this case is the seat id, screening id, ...

Link to comment
Share on other sites

Structure-wise, I agree with mac_gyver. This is really no different than the hotel booking system you were working on before. A single cinema booking can consist of multiple seats, much like a single hotel booking can consist of multiple rooms. Take a step back, think about what you know from past experience, and re-evaluate your current data design; in this case I very much doubt that a "booking" is a single seat.

Link to comment
Share on other sites

22 hours ago, mac_gyver said:

you should have a booking/reservation/order table, that holds the unique/one-time booking data

 

22 hours ago, mac_gyver said:

you would use this booking id to store the related booking item data, one row per item

But as in the original post, my booking table is there, I have different booking_id per seat, even if the seats were purchased together. So, surely, If I Buy 2 tickets right now, the booking_id should be the same. Like in the hotel system, if a user booked 4 rooms at once, the booking_id would be same for all four. I don't have that, I have different booking_id per seat, even if the seats were purchased together.

18 hours ago, Barand said:

I am assuming that this is an AJAX/Fetch process as you reference javscript in your initial post. Is it?

No. I mentioned JS in the initial post, but only the redirect is done in JS, there is no fetch call to the success page. Here is the relevant snippet:

 setTimeout(() => {
      updateSelectedSeat();
      alert("Seats booked successfully!");window.location.href = "success.php";

    }, 500);

JS is in the same state as my previous  version when you and mac_gyver helped me show seats that are already booked on the cinema seat map. I achieved that, since then the only change to the JS is the line:

window.location.href = "success.php";

 

12 hours ago, maxxd said:

A single cinema booking can consist of multiple seats

That's the thing, I don't have that in my database. I have the booking table sample data in my original post, but there is not a single booking_id attached to many seats like there should be.

Do I have to go back and change my data model? Or can there be a surgical intervention & put a band aid on it? Because after this success page is done, that's it with this project, its on to the next one.

Or shall I just use GET variables into this url:

window.location.href = "success.php";

 

Edited by webdeveloper123
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.