NHMaan
NHMaan

Reputation: 13

transfer variable betweet two php page

i have 3 page the first is html where i use then i send the data to the second page (php) with post where i have some condition, then i will send the data again for the third php page where i will put it in table (html) my probleme is the data don't send to the third php page

the 2nd page

if(isset($_POST['matier']) and isset($_POST['semaine']))
{
    $matier = $_POST['matier'] ;
    $semain = $_POST['semaine'] ;

    header('Location:EmploiMetierSemaine.php?'.$matier.' & '.$semaine);
}

the third page

<?php

                $matier = $_GET['m'] ;
                $semaine = $_GET['s'] ;
?>

any help please

Upvotes: 0

Views: 48

Answers (3)

Milad Abooali
Milad Abooali

Reputation: 728

Nowdays If in same case you need to pass a values to multiple pages consecutive with redirection, maybe it's better to review and redesign your program. in other word it's like you are doing something in wrong way.

However, your 2th page must be somthing like this:

$matier = $_POST['matier'] ?? NUll;
$semain = $_POST['semaine'] ?? NUll;

header('Location:EmploiMetierSemaine.php?m='.$matier.'&s'.$semaine);

And use $_GET on 3th page.

Upvotes: 0

Rkv88  -  Kanyan
Rkv88 - Kanyan

Reputation: 1332

in second page url should be like this EmploiMetierSemaine.php?m=matier&s=semaine

if(isset($_POST['matier']) and isset($_POST['semaine']))
{
    $matier = $_POST['matier'] ;
    $semaine = $_POST['semaine'] ;

    header('Location:EmploiMetierSemaine.php?m='.$matier.'&s='.$semaine);
}

Upvotes: 0

ArSeN
ArSeN

Reputation: 5258

You are not passing the params as parameters again but only values here:

header('Location:EmploiMetierSemaine.php?'.$matier.' & '.$semaine);

If you want to pass them as m and s you have to tell your location header so:

header('Location:EmploiMetierSemaine.php?m='.$matier.'&s='.$semaine);

Note that I also removed the spaces around the & since they don't make any sense in the URL.

Upvotes: 1

Related Questions