Using the value of $page, send a header to redirect the browser to the appropriate page:
--------8<--test.php----------
...
if($page==1)
{ header("Location:page2.php");
}
...
if($page==4)
{ header("Location:page4.php");
}
...
It almost goes without saying that test.php shouldn't output anything at least until after these redirections have been handled.