2021年4月10日星期六

How to redirect to a different page depending on the input

How can I redirect to a different page depending on what is selected on the form. For example if Cornerback and Interceptions is submitted than it should go to thirdpage.php.

Here is my code:

<!DOCTYPE html>  <html>    <head>    <title>Nfl records</title>  </head>    <body>    <form method="post">      Choose a postion:      <select name="cars">        <option value="cb">CornerBack</option>        <option value="S">Saftey</option>      </select>      </br>      Choose a stat:      <select name="stats">        <option value="int">Interceptions</option>        <option value="t">Tackles</option>      </select>      <input type="submit" value="Submit">  </body>      <?php        if(isset($_POST['submit']) {            $selected_val = $_POST['cars'];            $selected_val2 = $_POST['stats'];            if($selected_val == "cb" && $selected_val2 == "int") {                header("Location: thirdpage.php");             }        }      ?>    </form>    </html>
https://stackoverflow.com/questions/67041260/how-to-redirect-to-a-different-page-depending-on-the-input April 11, 2021 at 11:43AM

没有评论:

发表评论