$nextpage=$_POST['mainquestion'].'.php'; if (is_file($next_page)) header('location:'.$next_page); else header('location:main.php');