这是我的问题。
我从带有iframe的页面调用表单。 之后,我提交此表单(操作是将父页面重定向到另一个表单)。因此,我丢失了我在子页面中创建的会话(值)。
我不放我的代码,因为它太大了。
我可以做些什么来维护我的所有会话价值。
由于
这是我的孩子窗口......
<?php
session_start();
$num = $_POST["num"];
require('connexionClass.php');
$connexion = new Connexion();
$con = $connexion->open();
if($con){
mysql_select_db("test",$con);
//RECUPERATION DES INFORMATIONS DU PATIENT
$result = mysql_query("
SELECT *
FROM `patient` , `personne` , `adresse` , `telpers` , `telephone`
WHERE `Personne`.`idPersonne` = (
SELECT `idPersonne`
FROM `patient`
WHERE `numDossier` = '$num' )
AND `patient`.`idPersonne` = `Personne`.`idPersonne`
AND `telpers`.`idPersonne` = `Personne`.`idPersonne`
AND `adresse`.`idAdresse` = `Personne`.`idPersonne`
AND `telpers`.`idTel` = `Telephone`.`idTel`
");
while($row = mysql_fetch_array($result)){
if($row > 0){
$_SESSION["pName"] = $row["nom"];
$_SESSION["pPre"] = $row["prenom"];
$_SESSION["pSexe"] = $row["sexe"];
$_SESSION["pAnniv"] = $row["anniv"];
$_SESSION["pAssurance"] = $row["assurance"];
$_SESSION["pNumDossier"] = $row["numDossier"];
$_SESSION["pIdPersonne"] = $row["idPersonne"];
$_SESSION["pIdPatient"] = $row['ind']."-".$row["quartier"]."-".$row["num"];
$_SESSION["pIdAdresse"] = $row['idAdresse'];
$_SESSION["pNum"] = $row["numRue"];
$_SESSION["pRue"] = $row["rue"];
$_SESSION["pVille"] = $row["ville"];
$_SESSION["pIdTel"] = $row["idTel"];
$_SESSION["ptypeTel"] = $row["typeTel"];
$_SESSION["pTel"] = $row['ind']."-".$row["quartier"]."-".$row["num"];
}
}//WHILE
$query = ("
SELECT COUNT(*)
FROM `patient` , `personne` , `adresse` , `telpers` , `telephone`
WHERE `Personne`.`idPersonne` = (
SELECT `idPersonne`
FROM `patient`
WHERE `numDossier` = '$num' )
AND `patient`.`idPersonne` = `Personne`.`idPersonne`
AND `telpers`.`idPersonne` = `Personne`.`idPersonne`
AND `adresse`.`idAdresse` = `Personne`.`idPersonne`
AND `telpers`.`idTel` = `Telephone`.`idTel`
");
$results = mysql_query($query);
$values = mysql_fetch_assoc($results);
if($values["COUNT(*)"] ==1){
echo "<script> alert('Patient trouvé'); </script>";
?>
<html>
<head>
<style>
#kform{
width: 93.25%;
background: white;
padding: 10px 0 10px 5px;
margin: -2% 5% 0 3.5%;
}
.lab{ float:left; width: 30%; margin-bottom: 5px; }
.input{ margin-bottom: 5px; }
</style>
<script>
function redirect(){
window.parent.location = '../facture.php';
}
</script>
</head>
<body>
<div id = 'kform' class = 'hide'>
<form id = 'nonrep' name = 'nonrep' action = 'javascript:redirect();'>
<div class = 'lab'> # du patient : </div>
<div class = 'input'> <input type = 'text' id = 'num' name = 'num' size = '14' value = '<?php echo $_SESSION["pNumDossier"]; ?>' readonly/> </div>
<div class = 'lab'> Nom: </div>
<div class = 'input'> <input type = 'text' id = 'num' name = 'num' size = '14' value = '<?php echo $_SESSION["pName"]; ?>' readonly/> </div>
<div class = 'lab'> Prenom: </div>
<div class = 'input'> <input type = 'text' id = 'num' name = 'num' size = '14' value = '<?php echo $_SESSION["pPre"]; ?>' readonly/> </div>
<div class = 'lab'> Date de naissance: </div>
<div class = 'input'> <input type = 'text' id = 'num' name = 'num' size = '14' value = '<?php echo $_SESSION["pAnniv"]; ?>' readonly/> </div>
<div class = 'lab'> Numero Civic: </div>
<div class = 'input'> <input type = 'text' id = 'num' name = 'num' size = '14' value = '<?php echo $_SESSION["pNum"]; ?>' readonly/> </div>
<div class = 'lab'> Rue: </div>
<div class = 'input'> <input type = 'text' id = 'num' name = 'num' size = '14' value = '<?php echo $_SESSION["pRue"]; ?>' readonly/> </div>
<div class = 'lab'> Ville: </div>
<div class = 'input'> <input type = 'text' id = 'num' name = 'num' size = '14' value = '<?php echo $_SESSION["pVille"]; ?>' readonly/> </div>
<div class = 'lab'> Téléphone: </div>
<div class = 'input'> <input type = 'text' id = 'num' name = 'num' size = '14' value = '<?php echo $_SESSION["pTel"]; ?>' readonly/> </div>
<input type = 'submit' value = 'Continuer' style= "margin-left: 280px;"/>
</form>
</div>
</body>
</html>
<?php
}//VALUES = 1
else{
echo "<script> alert('Patient non trouvé'); </script>";
echo $query;
}
$connexion->close($con);
}//IF $CON
else
echo "<script> alert('No connection');</script>";
?>
我的REDIRECT PAGE
<!-- Les etapes d'une facture
1. CHOISIR LES MEDICAMENTS
2. choisir le patient
3. Confirmation de facture
-->
<?php session_start(); ?>
<html>
<head>
<style>
.title{
width: 90%;
background-color: black;
color: white;
padding: 10px 0 10px 5px;
margin: 0 5% 0 5%;
font-weight: bold;
text-align: center;
}
#kform{
width: 90%;
background: white;
padding: 10px 0 10px 5px;
margin: 0 5% 0 5%;
}
.gauche{float:left;}
.body{ width: 750px; background-color: #F2F2F2; }
#corps{ width: 100%; }
.nom{ width: 50%; }
.qte{ width: 15%; }
.prix{ width: 15%; padding-left: 10px;}
.bNom{ width: 45%; text-align: center; }
.bQte{ width: 6%; text-align:center; margin-left: 3%; margin-right: 12%; }
.bPrix{ width: 9%; text-align:center; margin-right: 4%; }
.medic{ margin: 10px 0 10px 10px;}
.barTitle{margin: 10px 0 20px 10px;}
.total{ width:70%; text-align:right; margin-right: 50px; float:left;}
.tot{ width:20%; float:left;}
</style>
<script>
function redirect(){ window.location = 'patient.php'; }
</script>
</head>
<body>
<div class = "body">
<!-- Including the menu -->
<?php
include('menu.php');
require('progressB.php');
?>
<div id = 'Index'> Commande > Etape # 3: Facture </div>
<?php
$progress = new Progress();
$progress->progressBar(100);
?>
<div id = "corps">
<div class = 'title'> Facture </div>
<div id = 'kform'>
<div class = 'barTitle'>
<div class = 'bNom gauche'><b>Nom</b></div>
<div class = 'bQte gauche'><b>Qté</b></div>
<div class = 'bPrix gauche'><b>Prix Un.</b></div>
<div class = 'bAction'><b>Total</b></div>
</div>
<?php
$connexion = new Connexion();
$con = $connexion->open();
if($con){
mysql_select_db("test",$con);
$query = "
SELECT *, `panier`.`qte`
FROM `panier` , `produit`
WHERE `panier`.`idPanier` = (
SELECT `idPanier`
FROM `specialiste`
WHERE `login` = '".$_SESSION["login"]."'
)
AND `produit`.`idProduit` = `panier`.`idProduit`
";
$j = 0;
$result = mysql_query($query);
if(!$result || mysql_num_rows($result)==0){
echo "Vous n'avez pas d'article dans votre panier";
echo "<input type = 'button' value = 'Continuer' style= 'margin-left: 280px;' onClick = 'javascript:redirect();' disabled/>";
}
else{
while($row = mysql_fetch_array($result)){
$_SESSION["total$j"] = $row["qte"] * $row["prix"];
echo "<div class = 'medic'>
<div id = 'nom$j' class = 'nom gauche'>".$row["nom"]."</div>
<div id = 'qte$j' class = 'qte gauche'>".$row["qte"]."</div>
<div id = 'prix$j' class = 'prix gauche'>".$row["prix"]." $</div>
<div id = 'img$j ' class = 'supprimer'>".$_SESSION["total$j"]." $</div>
<input type='hidden' id = 'id$j' value = '".$row["idProduit"]."'/>
</div>";
$j++;
}//WHILE
echo "<div id = 'prix' class = 'total'>SOUS-TOTAL </div>";
//CALCUL DU PRIX TOTAL SANS LES ASSURANCES
$prix = 0;
for($i = 0; $i < $j; $i++){
$prix = $prix + $_SESSION["total$i"];}
$_SESSION["totalFact"] = $prix;
echo "<div id = 'img$j ' class = 'tot'>".$_SESSION["totalFact"]." $</div>";
$query = "SELECT `patient`.`assurance` FROM `patient`,`personne` WHERE `patient`.`idPersonne` = ( SELECT `idPersonne` FROM `personne` WHERE `personne`.`nom` = '".$_SESSION["pName"]."' ) AND `patient`.`idPersonne` = `personne`.`idPersonne`";
echo $query;
$result = mysql_query($query);
while($row = mysql_fetch_array($result)){ echo $row["assurance"]; }
echo "<div class='assurance'>".$_SESSION["pAssurance"]."</div>";
}//ELSE
echo "<input type = 'button' value = 'Continuer' style= 'margin-left: 280px;' onClick = 'javascript:redirect();'/>";
}//$CON
$connexion->close($con); //CLOSE CONNECTION
?>
</div>
</div>
<!-- Including the footer -->
<?php include('footer.php'); ?>
</div>
</body>
</html>
我的错误
Notice: Undefined index: pName in C:\Server\www\medical-clinic\facture.php on line 108
Notice: Undefined index: pAssurance in C:\Server\www\medical-clinic\facture.php on line 112
答案 0 :(得分:0)
您在该代码块中没有session_start()
次调用。除非您启动会话,否则在脚本退出时不会为您保留写入$ _SESSION超全局的任何数据。