Génération de page grâce à un compteur
Bonjour à tous,
Un petit message pour vous demander de l'aide pour mon système d'authentification. Pour mes pages de saisie de l'adresse de livraison et également de facturation, il est possible d'avoir plusieurs adresses de livraison et facturation. Actuellement sur ma page inscription facturation, j'ai mis un bouton pour aller sur un formulaire identique de remplissage d'une deuxième adresse de facturation, etc... comme des poupées gigognes mais mon système a ses limites puisque je génère moi-même les formulaires. Je souhaite pouvoir créer un système qui permettrait de générer des pages de saisie d'adresse dynamiquement et infini en fait, pas contraint par le nombre déjà préparé.
Voici ma page comme elle est conçue actuellement :
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 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323
|
<?php
session_start(); // En premier dans la page
if (isset($_POST['id']))
{
$_SESSION['id_prospect'] = $_POST['id'];
}
//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 !';
}
}
?>
<!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"><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="error">*</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="error">*</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="error">*</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="error">*</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="error">*</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="error">*</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="Estonia"<?php if($_SESSION['facturation']['pays_facturation'] == 'Estonia') echo "selected" ;?>>Estonia</option>
<option value="Finland"<?php if($_SESSION['facturation']['pays_facturation'] == 'Finland') echo "selected" ;?>>Finland</option>
<option value="France"<?php if($_SESSION['facturation']['pays_facturation'] == 'France') echo "selected" ;?>>France</option>
<option value="French Guiana"<?php if($_SESSION['facturation']['pays_facturation'] == 'French Guiana') echo "selected" ;?>>French Guiana</option>
<option value="Georgia"<?php if($_SESSION['facturation']['pays_facturation'] == 'Georgia') echo "selected" ;?>>Georgia</option>
<option value="Germany"<?php if($_SESSION['facturation']['pays_facturation'] == 'Germany') echo "selected" ;?>>Germany</option>
<option value="Ukraine"<?php if($_SESSION['facturation']['pays_facturation'] == 'Ukraine') echo "selected" ;?>>Ukraine</option>
<option value="USA"<?php if($_SESSION['facturation']['pays_facturation'] == 'USA') echo "selected" ;?>>USA</option>
</select>
<span class="error">*</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="error">*</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="error">*</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"><input type="button" name="Other billing adress" class="TexteFormulaireBleuDessous2" value=">> Other billing adress" OnClick="window.location.href='inscriptionFacturation2.php'"/> 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="error">* Must be 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="86" 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="114" 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="273"> </td>
<td width="39"> </td>
<td width="109"> </td>
<td width="116"><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> |
Je dois retravailler ma table de manière à n'avoir qu'une seule série de champs pour les adresses facturation et livraison avec un id et un identifiant style l ou f selon livraison et facturation.
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
|
Structure de la table `facturation`
--
CREATE TABLE IF NOT EXISTS `facturation` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`labsf` varchar(255) NOT NULL,
`companyf` varchar(255) NOT NULL,
`adressf` varchar(255) NOT NULL,
`batf` varchar(255) NOT NULL,
`code_postalf` varchar(255) NOT NULL,
`villef` varchar(255) NOT NULL,
`paysf` varchar(255) NOT NULL,
`telf` int(11) NOT NULL,
`faxf` int(11) NOT NULL,
`id_prospect` int(11) NOT NULL,
`activer` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Structure de la table `livraison`
--
CREATE TABLE IF NOT EXISTS `livraison` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`labsf` varchar(255) NOT NULL,
`companyf` varchar(255) NOT NULL,
`adressf` varchar(255) NOT NULL,
`batf` varchar(255) NOT NULL,
`code_postalf` varchar(255) NOT NULL,
`villef` varchar(255) NOT NULL,
`paysf` varchar(255) NOT NULL,
`telf` int(11) NOT NULL,
`faxf` int(11) NOT NULL,
`id_prospect` int(11) NOT NULL,
`activer` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; |
Est-ce que vous pouvez me conseiller, me diriger vers un tuto qui reprend cette idée ? Je vois ce que j'aimerai avoir au final mais ça se complique pour y arriver en fait !
Merci d'avance pour votre aide ;)