PHP Redirect to new page after form submission

前端 未结 5 807
不知归路
不知归路 2021-01-23 21:51

I have a form, which redirects the user to \"page1.php\" after the form is submitted. What I want to do is to redirect the user to \"page2.php\" after the form is submitted, but

5条回答
  •  一生所求
    2021-01-23 22:38

    In your situation, you can just simple check for the posted data. Like

    $username = $_POST['username'];
    $age = $_POST['age'];
    if($username&&$age){ /* This is to check if the variables are not empty  */
     // redirect to page2
    }
    

    It is logical that if those are not empty, meaning they are posted. Even if they are empty, as long as you get there, that means it was posted. There is no need to check if posted or not, what needs to be checked was, if posted data was there.

    I hope I made it clear. ^_^ but making sure is not bad at all. Happy coding friend.

提交回复
热议问题