Petit nouveau ! |
4 Messages
07 févr. 2012, 17:50
merci pour ta réponse mais je ne pense pas avoir tout compris...
J'ai modifié mes intitulés de session pour simplifier la compréhension :
<?php
session_start(); // En premier dans la page
//valeurs champs premier formulaire = inscription2.php
if (isset($_POST['labs'])) {
$_SESSION['civilite2']['labs'] = $_POST['labs'];}
if (isset($_POST['company'])) {
$_SESSION['civilite2']['company'] = $_POST['company'];}
if (isset($_POST['adress'])) {
$_SESSION['civilite2']['adress'] = $_POST['adress'];}
if (isset($_POST['bat'])) {
$_SESSION['civilite2']['bat'] = $_POST['bat'];}
if (isset($_POST['code_postal'])) {
$_SESSION['civilite2']['code_postal'] = $_POST['code_postal'];}
if (isset($_POST['ville'])) {
$_SESSION['civilite2']['ville'] = $_POST['ville'];}
if (isset($_POST['pays'])) {
$_SESSION['civilite2']['pays'] = $_POST['pays'];}
if (isset($_POST['tel'])) {
$_SESSION['civilite2']['tel'] = $_POST['tel'];}
if (isset($_POST['fax'])) {
$_SESSION['civilite2']['fax'] = $_POST['fax'];}
//On récupère ensuite les valeurs du formulaire de facturation au cas où elles auraient été modifié
$_SESSION['facturation'] = $_SESSION['civilite2'];
if (isset($_POST['labs_facturation'])) {
$_SESSION['facturation']['labs'] = $_POST['labs_facturation'];}
if (isset($_POST['company_facturation'])) {
$_SESSION['facturation']['company'] = $_POST['company_facturation'];}
if (isset($_POST['adress_facturation'])) {
$_SESSION['facturation']['adress'] = $_POST['adress_facturation'];}
if (isset($_POST['bat_facturation'])) {
$_SESSION['facturation']['bat'] = $_POST['bat_facturation'];}
if (isset($_POST['code_postal_facturation'])) {
$_SESSION['facturation']['code_postal'] = $_POST['code_postal_facturation'];}
if (isset($_POST['ville_facturation'])) {
$_SESSION['facturation']['ville'] = $_POST['ville_facturation'];}
if (isset($_POST['pays_facturation'])) {
$_SESSION['facturation']['pays'] = $_POST['pays_facturation'];}
if (isset($_POST['tel_facturation'])) {
$_SESSION['facturation']['tel'] = $_POST['tel_facturation'];}
if (isset($_POST['fax_facturation'])) {
$_SESSION['facturation']['fax'] = $_POST['fax_facturation'];}
// on initialise le tableau des erreurs
$erreurs= array(
"labs_facturation" => array("msg" => ""),
"company_facturation" => array("msg" => ""),
"adress_facturation" => array("msg" => ""),
"bat_facturation" => array("msg" => ""),
"code_postal_facturation" => array("msg" => ""),
"ville_facturation" => array("msg" => ""),
"pays_facturation" => array("msg" => ""),
"tel_facturation" => array("msg" => ""),
"fax_facturation" => array("msg" => ""),
);
$error_exist= false;
$erreur2= "";
$labs_facturation= (isset($_POST['labs_facturation'])) ?($_POST['labs_facturation']):("");
$company_facturation= (isset($_POST['company_facturation']))?($_POST['company_facturation']):("");
$adress_facturation= (isset($_POST['adress_facturation']))?($_POST['adress_facturation']):("");
$bat_facturation= (isset($_POST['bat_facturation']))?($_POST['bat_facturation']):("");
$code_postal_facturation= (isset($_POST['code_postal_facturation']))?($_POST['code_postal_facturation']):("");
$ville_facturation= (isset($_POST['ville_facturation']))?($_POST['ville_facturation']):("");
$pays_facturation= (isset($_POST['pays_facturation']))?($_POST['pays_facturation']) :("");
$tel_facturation= (isset($_POST['tel_facturation'])) ?($_POST['tel_facturation']):("");
$fax_facturation= (isset($_POST['fax_facturation'])) ?($_POST['fax_facturation']) :("");
// on teste si le visiteur a soumis le formulaire
if(isset($_POST['inscription'])) {
//si tous les champs sont vides(verif avec empty), erreur2 = tous les champs sont requis
if(empty($labs_facturation) || empty($company_facturation) || empty($adress_facturation) || empty($bat_facturation) || empty($code_postal_facturation) || empty($ville_facturation) || empty($pays_facturation) || empty($tel_facturation) || empty($fax_facturation)) {
$erreur2 = "All fields are requested !";
$error_exist= true;
}
// test sur laboratoire
$labs_ko= (strlen($labs_facturation) < 2);
if($labs_ko) {
$erreurs["labs_facturation"]["msg"].="Fill the field labsf !<br/>";
$error_exist= true;
}
// test sur company
$company_ko= (strlen($company_facturation) < 2);
if($company_ko) {
$erreurs["company_facturation"]["msg"].="Fill the field company !<br/>";
$error_exist= true;
}
// test sur adress
$adress_ko= (strlen($adress_facturation) < 2);
if($adress_ko) {
$erreurs["adress_facturation"]["msg"].="Fill the field adress !<br/>";
$error_exist= true;
}
// test sur bat
$bat_ko= (strlen($bat_facturation) < 2);
if($bat_ko) {
$erreurs["bat_facturation"]["msg"].="Fill the field building !<br/>";
$error_exist= true;
}
// test sur code postal
$code_postal_ko= (strlen($code_postal_facturation) < 2);
if($code_postal_ko) {
$erreurs["code_postal_facturation"]["msg"].="Fill the field postal code !<br/>";
$error_exist= true;
}
// test sur city
$ville_ko= (strlen($ville_facturation) < 2);
if($ville_ko) {
$erreurs["ville_facturation"]["msg"].="Fill the field city !<br/>";
$error_exist= true;
}
// test sur tel
if(!is_numeric($tel_facturation)) {
$erreurs["tel_facturation"]["msg"].= "This fiels must contain only figures !<br/>";
}
// test sur fax
if(!is_numeric($fax_facturation)) {
$erreurs["fax_facturation"]["msg"].= "This fiels must contain only figures !<br/>";
}
if(!$error_exist) {
// et on commence la session qui s'appelle email
$_SESSION['email'] = $email;
header('Location: inscriptionLivraison.php');
exit();
}
else {
$erreur2 = 'One of the fields is empty !';
}
}
// Rajouter condition si case cochée "un autre compte pour acheter"
?>
<!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 name="facturation" action="inscriptionFacturation.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>
<p class="TitreFormulaire1">Billing adress #1<br/>
<span class="ClickHere">Does my billing adress different from this one ?</span> <br/>
</p>
<table width="740" border="0" cellpadding="0" cellspacing="0" >
<tr>
<td width="117"><label for="labs_facturation" class="TexteLogin">Dept/Labs : </label></td>
<td width="320"><input name="labs_facturation" type="text" class="loginRemplissage" SIZE="45" value="<?php if (!empty($_SESSION['facturation']['labs'])) echo htmlentities(trim($_SESSION['facturation']['labs']));
?>"/>
<span class="TexteCheck">*</span></td>
<td width="295" colspan="3" class="error2"> <?php echo $erreurs["labs_facturation"]["msg"]; ?> </td>
</tr>
<tr>
<td width="117"><label for="company_facturation" class="TexteLogin">Company : </label></td>
<td width="320"><input name="company_facturation" type="text" class="loginRemplissage" SIZE="45" value="<?php if (!empty($_SESSION['facturation']['company'])) echo htmlentities(trim($_SESSION['facturation']['company'])); ?>"/>
<span class="TexteCheck">*</span></td>
<td colspan="3" class="error2"> <?php echo $erreurs["company_facturation"]["msg"]; ?></td>
</tr>
<tr>
<td width="117"><label for="adress_facturation" class="TexteLogin">Adress : </label></td>
<td><input name="adress_facturation" type="text" class="loginRemplissage" SIZE="45" value="<?php if (!empty($_SESSION['facturation']['adress'])) echo htmlentities(trim($_SESSION['facturation']['adress'])); ?>"/>
<span class="TexteCheck">*</span></td>
<td colspan="3" class="error2"> <?php echo $erreurs["adress_facturation"]["msg"]; ?> </td>
</tr>
<tr>
<td width="117"><label for="bat_facturation" class="TexteLogin">Building : </label></td>
<td width="320"><input name="bat_facturation" type="text" class="loginRemplissage" SIZE="45" value="<?php if (!empty($_SESSION['facturation']['bat'])) echo htmlentities(trim($_SESSION['facturation']['bat'])); ?>"/>
<span class="TexteCheck">*</span></td>
<td colspan="3" class="error2"> <?php echo $erreurs["bat_facturation"]["msg"]; ?> </td>
</tr>
<tr>
<td width="117"><label for="code_postal_facturation" class="TexteLogin">Zip code : </label></td>
<td width="320"><input name="code_postal_facturation" type="text" class="loginRemplissage" SIZE="20" value="<?php if (!empty($_SESSION['facturation']['code_postal'])) echo htmlentities(trim($_SESSION['facturation']['code_postal'])); ?>"/>
<span class="TexteCheck">*</span></td>
<td colspan="3" class="error2"> <?php echo $erreurs["code_postal_facturation"]["msg"]; ?> </td>
</tr>
<tr>
<td width="117"><label for="ville_facturation" class="TexteLogin">City : </label></td>
<td width="320"><input name="ville_facturation" type="text" class="loginRemplissage" SIZE="45" value="<?php if (!empty($_SESSION['facturation']['ville'])) echo htmlentities(trim($_SESSION['facturation']['ville'])); ?>"/>
<span class="TexteCheck">*</span></td>
<td colspan="3" class="error2"> <?php echo $erreurs["ville_facturation"]["msg"]; ?> </td>
</tr>
<tr>
<td width="117"><label for="pays_facturation" class="TexteLogin">Country : </label></td>
<td width="320">
<select class="loginRemplissage" style="width:130px;" name="pays_facturation" id="pays_facturation" size="1">
<option value="Algeria"<?php if($_SESSION['facturation']['pays_facturation'] == 'Algeria') echo "selected"; ?>>Algeria</option>
<option value="Argentina"<?php if($_SESSION['facturation']['pays_facturation'] == 'Argentina') echo "selected" ; ?>>Argentina</option>
<option value="USA"<?php if($_SESSION['facturation']['pays_facturation'] == 'USA') echo "selected" ;?>>USA</option>
</select>
<span class="TexteCheck">*</span></td>
<td colspan="3" class="error2"> </td>
</tr>
<tr>
<td width="117"><label for="tel_facturation" class="TexteLogin">Tel : </label></td>
<td width="320"><input name="tel_facturation" type="text" class="loginRemplissage" SIZE="30" value="<?php if (!empty($_SESSION['facturation']['tel'])) echo htmlentities(trim($_SESSION['facturation']['tel'])); ?>"/>
<span class="TexteCheck">*</span></td>
<td colspan="3" class="error2"> <?php echo $erreurs["tel_facturation"]["msg"]; ?> </td>
</tr>
<tr>
<td width="117"><label for="fax_facturation" class="TexteLogin">Fax : </label></td>
<td width="320"><input name="fax_facturation" type="text" class="loginRemplissage" SIZE="30" value="<?php if (!empty($_SESSION['facturation']['fax'])) echo htmlentities(trim($_SESSION['facturation']['fax'])); ?>"/>
<span class="TexteCheck">*</span></td>
<td colspan="3" class="error2"> <?php echo $erreurs["fax_facturation"]["msg"]; ?> </td>
</tr>
<tr>
<td> </td>
<td colspan="7" class="TexteErreur"><?php if (isset($erreur2)) echo '<br />',$erreur2; ?></td>
</tr>
<tr>
<td> </td>
<td colspan="7" class="TexteErreur"> </td>
</tr>
<tr>
<td> </td>
<td colspan="7" class="texteCheckBoxT" valign="top"><strong><a href="inscriptionFacturation2.php" class="TexteFormulaireBleuDessous">>> </a></strong> I have other accounts from wich I can buy. </td>
</tr>
<tr>
<td> </td>
<td colspan="7" class="TexteCheck"> </td>
</tr>
<tr>
<td> </td>
<td colspan="7" class="TexteCheck">* Must be mandatory filled </td>
</tr>
<tr>
<td> </td>
<td colspan="7" class="TexteCheck"> </td>
</tr>
<tr>
<td colspan="8"><table width="737" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="82" class="loginRemplissage2"><div align="center"><strong><img src="images/Fleche.jpg" alt="" width="16" height="16" align="left" class="AlignementFleche5"/><a href="inscription1.php" class="loginRemplissage2Copie">Account</a></strong></div></td>
<td width="110" class="loginRemplissage2"><div align="center"><strong><img src="images/Fleche.jpg" alt="" width="16" height="16" align="left" class="AlignementFleche5"/><a href="InterfineChemicals.php" class="loginRemplissage2Copie">Field of interest </a></strong> </div></td>
<td width="130" class="loginRemplissage2"><div align="center"><strong><img src="images/Fleche.jpg" alt="" width="16" height="16" align="left" class="AlignementFleche5"/><a href="InterfineChemicals.php" class="loginRemplissage2Copie">First Billing adress </a></strong> </div></td>
<td width="133"> </td>
<td width="28"> </td>
<td width="77"> </td>
<td width="97"> </td>
<td width="80"><input type="submit" name="inscription" class="AlignementNext" value=""/></td>
</tr>
</table></td>
</tr>
<tr>
<td> </td>
<td colspan="7" class="TexteCheck"> </td>
</tr>
</td>
</tr>
</table>
</fieldset>
</form><br/>
</div>
</body>
</html>