You can also use a session var ($_[SESSION]) to store an array containing all the pages the user already visited. Using this, you will be able to create the logic to the "Next" button. You can also use the same logic above using diferent values in history.go funciton.
Anyway, I think you should implement the "Next" button explicitly, like in a wizard. Ohterwise, I cant realize how you would perform such task.