0

I use the post method and try to use the if function, but it does not work

I want to Redirect admin_login.php page and student_login.php page. But when I click on Admin Login or Student Login it is not redirect.

<body>
     <div class="container">
         
         <form action="" method="post">
             <h1>Student Management System</h1>
             <input type="button" name="admin_login" class="button" value="Admin Login">
             <input type="button" name="student_login" class="button" value="Student Login">
         </form>
     </div>
     <?php
     
        if(isset($_POST['admin_login'])){
            echo "Yes, mail is set";
            header("Location: admin_login.php");
        }
        if(isset($_POST['student_login'])){
            header("Location: student_login.php");
        }
     ?>
</body>
aynber
  • 22,380
  • 8
  • 50
  • 63
  • 1
    Because there must be no content before any [header](https://www.php.net/manual/en/function.header.php) call – brombeer May 18 '22 at 16:24
  • 2
    Why are you using a form, POST requests, and redirects? This looks like a job for simple links. – Quentin May 18 '22 at 16:26

0 Answers0