I've done it like this in the past, using sessions, but there are alot of different ways.
// In this case, $count is a remaining number out of a total number ex. 3 out of 10 so count would be 7 and Next button would be displayed
if ($count > 0) {
// then set a session var to match
$_SESSION['submit'] = "next";
echo '<div><button type="submit" name="next">Next</button>';
} else {
$_SESSION['submit'] = "done";
echo '<div><button type="submit" name="done">Done</button>';
echo "Thank you for completing survey!<br />Hit <i>Done</i> when finished!";
}
// Then you can check
if ($_SESSION[submit] == "next") {
do something
} else {
do something else
}
Not exact, and not tested, but should get you going in the right direction. Hope that helps