0

I have this form :

I want to know if there is some way that when a user choose directeur from niveau option field to be redirected to the directeur's page, and if he is choose some other value he will be redirected to this value's page.

I know the method using JavaScript but I have to work only with PHP, and to do all manipulation on that form in the same page where the page is.

I tried this :

if(isset($_POST['submit']))
   {
      if($_POST['niveau'] == 'directeur')
          header('Location: directeur.php');

   }

but this will redirect the user to the page without the $_POST values. I know that there I can send some values with the url and retreive them use $_GET but I have to use only $_POST.

so is there any other method to do that ?

Yukina Yukinatte
  • 33
  • 1
  • 2
  • 6

1 Answers1

1

Yes, use $_SESSION:

session_start();
if(isset($_POST['submit']))
{
    if($_POST['niveau'] == 'directeur')
        $_SESSION['info'] = $_POST;
        header('Location: directeur.php');
    }
}

And in directeur.php:

session_start();
$niveau = $_SESSION['info'];
A. Rodas
  • 20,171
  • 8
  • 62
  • 72