formulaire multipages avec sessions
Bonjour à tous,
Je construis un formulaire multipages avec des sessions et je n'arrive pas à emmener mes données en session. Il faudrait qu'elles s'affichent sur mon formulaire actif alors qu'elles ont été saisies dans le formulaire précédent.
Je n'enregistre pas les données dans les sessions mais la fonction session_register est dépréciée apparemment alors comment dois-je m'y prendre ?
Merci pour votre aide.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
|
<?php
session_start(); // En premier dans la page
if(!isset($_SESSION["email"]) || $_SESSION["email"] == "") {
//enregistrement des données dans la session
if (isset($_POST['email'])) {
$_SESSION['email'] = $_POST['email'];} else {unset($_SESSION['email']);}
if (isset($_POST['titre'])) {
$_SESSION['titre'] = $_POST['titre'];} else {unset($_SESSION['titre']);}
if (isset($_POST['nom'])) {
$_SESSION['nom'] = $_POST['nom'];} else {unset($_SESSION['nom']);}
if (isset($_POST['prenom'])) {
$_SESSION['prenom'] = $_POST['prenom'];} else {unset($_SESSION['prenom']);}
if (isset($_POST['password'])) {
$_SESSION['password'] = $_POST['password'];} else {unset($_SESSION['password']);}
// on initialise le tableau des erreurs
$erreurs= array(
"labs" => array("msg" => ""),
"company" => array("msg" => ""),
"adress" => array("msg" => ""),
"bat" => array("msg" => ""),
"code_postal" => array("msg" => ""),
"ville" => array("msg" => ""),
"pays" => array("msg" => ""),
"tel" => array("msg" => ""),
"fax" => array("msg" => ""),
);
$error_exist= false;
$erreur2= "";
$labs= (isset($_POST['labs'])) ?($_POST['labs']) :("");
$company= (isset($_POST['company'])) ?($_POST['company']) :("");
$adress= (isset($_POST['adress'])) ?($_POST['adress']) :("");
$bat= (isset($_POST['bat'])) ?($_POST['bat']) :("");
$code_postal= (isset($_POST['code_postal'])) ?($_POST['code_postal']) :("");
$ville= (isset($_POST['ville'])) ?($_POST['ville']) :("");
$pays= (isset($_POST['pays'])) ?($_POST['pays']) :("");
$tel= (isset($_POST['tel'])) ?($_POST['tel']) :("");
$fax= (isset($_POST['fax'])) ?($_POST['fax']) :("");
// on teste si le visiteur a soumis le formulaire
if(isset($_POST['inscription'])) {
// conditions qui testent les données remplies dans formulaire
if(!$error_exist) {
// et on commence la session qui s'appelle email
$_SESSION['email'] = $email;
header('Location: InterfineChemicals.php');
exit();
}
else {
$erreur2 = 'One of the fields is empty !';
}
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//FR" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
</head>
<body>
<div id="contour_formulaire">
<form action="inscription2.php" method="POST">
<fieldset style="border-color:#73aad2;border-size:2px;" width="625">
<legend class="titre_labelaut"> Four steps and few clicks...<span class="Style4"></span></legend>
<?php
print_r($_SESSION) ;
?>
<table width="628" border="0" cellpadding="0" cellspacing="0" >
<tr>
<td width="89"> <label for="labs" class="TexteLogin">Dept/Labs : </label></td>
<td width="199"><input name="labs" type="text" class="loginRemplissage" SIZE="30" value="<?php if (isset($_POST['email'])) echo htmlentities(trim($_POST['email'])); ?>"/><span class="error">*</span></td>
<td colspan="6" class="error2"> <?php echo $erreurs["email"]["msg"]; ?> </td>
</tr> |