Your form will post back answers to your server. Your server must validate those answers. If the answers are valid, you should store them in the database. If the answers are invalid, you'll want to re-render the form, probably populated with the user's inputs, and display some kind of error, and repeat this process.
If the user's answers are valid, you'll write them to the database and redirect the user to the next page. On this next request, you can use the existence of answers for the first page to determine whether page 2 should be accessible. If not, you need to redirect them to the first page.
The extremely simplified logic within each page will look something like this:
page1.php
Do I have answers for page 1 questions?
No: Render page 1 questions
Yes: Redirect to page 2
page2.php
Do I have answers for page 1 questions?
No: redirect to page 1
Yes:
Do I have answers for page 2 questions?
No: Render page 2 questions
Yes: Redirect to page 3
page3.php
Do I have answers for page 1 questions?
No: redirect to page 1
Yes:
Do I have answers for page 2 questions?
No: Redirect to page 2
Yes:
Do I have answers for page 3 questions?
No: Render page 3 questions
Yes: Render "you are finished" page
Or more generally, each page should find the first page that doesn't have answers, and (if that's not the current page) redirect to that page.