zit_zit | voici le chef d'oeuvre...
Code :
- <td><div align="right"></div></td>
- <td colspan="2" align="center"> </td>
- </tr>
- <tr>
- <td height="40"><img src="images/fleche.gif" height="10" width="9"> Nom société: </td>
- <td width="158"><input type="text" name="ste" value="<? if(isset($_POST["ste"]))
- {$_SESSION["societe"]=$_POST["ste"];
- echo $_SESSION["societe"];}?>" ></td>
- <td width="105"> </td>
- <td width="308" colspan="2" rowspan="9">
- <?
- //verirfie la validite du mail saisie
- function valid_mail($email)
- {
- if(!eregi("^[_A-Za-z0-9.-]+[^.]@[^.][A-Za-z0-9.-]{2,}[.][a-z]{2,4}$",$email))
- {return "le mail est incorrect";}
- else
- {return "ok";}
- }
- //creer un mot de pass aleatoire du type Hkkkk00
- function mot_pass()
- {
- //mt_rand fonction php de nombre aleatoire (MIN,MAX)
- $a=chr(mt_rand(65,90));
- $b=chr(mt_rand(97,122));
- $c=chr(mt_rand(97,122));
- $d=chr(mt_rand(97,122));
- $e=chr(mt_rand(97,122));
- $f=chr(mt_rand(48,57));
- $g=chr(mt_rand(48,57));
- $pass=$a.$b.$c.$d.$e.$f.$g;
- return($pass);
- }
- function verif_donne($ste,$nom)
- {
- global $result;
- print "$ste";
- print "$nom";
- if($ste==$result->nomsociete and $nom==$result->nom)
- {return "redondance";}
- else
- {return "ok";}
- }
- function verif_num($chaine)
- {
- for ($i=0; $i < strlen($chaine); $i++)
- {
- $cpt=0;
- $asc=ord(substr($chaine, $i, 1));
- if (($asc<48) xor ($asc>57))
- {$cpt++;
- return $cpt;
- }
- }
- }
- if (isset($_POST["ste"],$_POST["nom"],$_POST["prenom"],$_POST["adr"],$_POST["cp"],$_POST["ville"],$_POST["mail"],
- $_POST["tel"],$_POST["fax"]))
- {
- // connection a mysql sur le serveur host par l'utilisateur cedric avec le mot de pass emilie et a la base de donnee
- $connection=mysql_connect("xxxx","xxx","xxx" ) or die("il y a une couille ".mysql_error());
- mysql_select_db("test" ) or die("base de donnee non existante".mysql_error());
- // appelle de la fontion valid_mail
- global $email;
- global $cp;
- global $ch;
- global $tel;
- global $num;
- global $fax;
- global $fax2;
- $email=valid_mail($_POST["mail"]);
- $verif="select nomsociete, nom from client where nomsociete = '".$_POST["ste"]."' and nom='".$_POST["nom"]."'";
- $query=mysql_query ($verif,$connection);
- $result=mysql_fetch_object($query);
- //#################### verification de la redondance dans la table #################
- if(!empty($_POST["ste"]) && !empty($_POST["nom"]) and ($_POST["ste"]==$result->nomsociete and $_POST["nom"]==$result->nom) )
- {
- if($_POST["ste"]==$result->nomsociete and $_POST["nom"]==$result->nom)
- { ?>
- <script language="javascript">
- alert("Vous êtes déjà inscris si vous avez oublié votre passe cliquez sur le lien en bas de page" );
- </script>
- <? }
- }
- //##################################################################################
- else{
- //######################## controle des champs saisis ###############################
- if($_POST["ste"]==NULL)
- {print "<p class=couleur>le champ société est vide</p>";}
- /*else
- {$_SESSION["societe"]=$_POST["ste"];
- print $_SESSION["societe"];}*/
- if($_POST["nom"]==NULL)
- {print "<p class=couleur>le champ nom est vide</p>";}
- if($_POST["prenom"]==NULL)
- {print "<p class=couleur>le champ prenom est vide</p>";}
- if($_POST["adr"]==NULL)
- {print "<p class=couleur>le champ adresse est vide</p>";}
- $cp=strlen($_POST["cp"]);
- $ch=verif_num($_POST["cp"]);
- if($_POST["cp"]==NULL)
- {print "<p class=couleur>le champ code postal est vide</p>";}
- elseif($ch==1)
- {print "<p class=couleur>le champ code postal doit être numérique </p>";}
- elseif($cp<5)
- {print "<p class=couleur> le champ code postal est incorrect</p>";}
- if($_POST["ville"]==NULL)
- {print "<p class=couleur>le champ ville est vide</p>";}
- if($_POST["mail"]==NULL)
- {print "<p class=couleur>le champ e-mail est vide</p>";}
- elseif($email!="ok" )
- {print"<p class=couleur>$email</p>";}
- $tel=strlen($_POST["tel"]);
- $num=verif_num($_POST["tel"]);
- if($_POST["tel"]==NULL)
- {print "<p class=couleur>le champ telephone est vide</p>";}
- elseif($num==1)
- {print "<p class=couleur>le champ telephone doit être numérique</p>";}
- elseif($tel<10)
- {print"<p class=couleur>le champ téléphone doit être sous cette forme: 0487477880</p>";}
- $fax=strlen($_POST["fax"]);
- $fax2=verif_num($_POST["fax"]);
- if($_POST["fax"]==NULL)
- {print "<p class=couleur>le champ fax est vide</p>";}
- elseif($fax2==1)
- {print "<p class=couleur>le champ fax doit être numérique</p>";}
- elseif($fax<10)
- {print"<p class=couleur>le champ fax doit être sous cette forme: 0487877880</p>";}
- //creation d'un mot de passe pour la nouvelle personne avec l'appelle de la fonction mot_pass;
- $pass=mot_pass();
- //############################## revalidation des champs pour inserer dans la base de donnee ##############################
- if($_POST["ste"]!=NULL&&$_POST["nom"]!=NULL&&$_POST["prenom"]!=NULL&&$_POST["adr"]!=NULL&&$_POST["cp"]!=NULL&&
- $_POST["ville"]!=NULL&&$_POST["tel"]!=NULL&&$_POST["fax"]!=NULL and $email=="ok" and $fax==10 and $tel==10 and $cp==5 and $num==NULL and $fax2==NULL && $ch==NULL)
- {
- $requette= "insert into client values(".chr(39).$_POST["ste"].chr(39).",".chr(39).$_POST["nom"].chr(39).",".chr(39).$_POST["prenom"].chr(39).","
- .chr(39).$_POST["adr"].chr(39).",".chr(39).$_POST["cp"].chr(39).",".chr(39).$_POST["ville"].chr(39).",".chr(39).$_POST["mail"].chr(39).","
- .chr(39).$_POST["tel"].chr(39).",".chr(39).$_POST["fax"].chr(39).",".chr(39).$pass.chr(39).",".chr(39).date("Y-m-j" ).chr(39).","
- .chr(39).date("G\:i\:s",time()).chr(39)." )";
- mysql_query($requette,$connection);
- mysql_close($connection);
- if (file_exists(".htpasswrd.txt" ))
- {
- ($fichier=fopen(".htpasswrd.txt",'r+'))or die("impossible d'ouvrir le fichier" );
- $ligne=fgets($fichier);
- while (!feof($fichier))
- {$ligne=fgets($fichier);}
- fwrite($fichier,$_POST["ste"].":".crypt ($pass).chr(13).chr(10));
- fclose($fichier);
- $_SESSION["va"]="ok";
- }
- }
- }
- }
- session_unset();
- // variable utilisé pour effacer le champ invalide saisie par l'utilisateur
- global $null;
- $null=NULL;
- ?>
- </td>
- </tr>
- <tr>
- <td width="124" height="40"><img src="images/fleche.gif" height="10" width="9"> Nom:</td>
- <td><input type="text" name="nom" value="<? if(isset($_POST["nom"]))
- {$_SESSION["nom"]=$_POST["nom"];
- echo $_SESSION["nom"];}?>"></td>
- <td> </td>
- </tr>
- <tr>
- <td width="124" height="40"><img src="images/fleche.gif" height="10" width="9"> Prénom:</td>
- <td><input type="text" name="prenom" value="<? if(isset($_POST["prenom"]))
- {$_SESSION["prenom"]=$_POST["prenom"];
- echo $_SESSION["prenom"];}?>"></td>
- <td> </td>
- </tr>
- <tr>
- <td width="124" height="40"><img src="images/fleche.gif" height="10" width="9"> Adresse:</td>
- <td><input type="text" name="adr" value="<? if(isset($_POST["adr"]))
- {$_SESSION["adr"]=$_POST["adr"];
- echo $_SESSION["adr"];}?>"></td>
- <td> </td>
- </tr>
- <tr>
- <td width="124" height="40"><img src="images/fleche.gif" height="10" width="9"> Code Postal:</td>
- <td><input name="cp" type="text" maxlength="5" value="<? if(isset($_POST["cp"]) and $ch==0 and $cp==5)
- {$_SESSION["cp"]=$_POST["cp"];
- echo $_SESSION["cp"];}
- else
- {echo $null;}?>"></td>
- <td> </td>
- </tr>
- <tr>
- <td width="124" height="40"><img src="images/fleche.gif" height="10" width="9"> Ville:</td>
- <td><input type="text" name="ville" value="<? if(isset($_POST["ville"]))
- {$_SESSION["ville"]=$_POST["ville"];
- echo $_SESSION["ville"];}?>"></td>
- <td> </td>
- </tr>
- <tr>
- <td width="124" height="40"><img src="images/fleche.gif" height="10" width="9"> E-mail:</td>
- <td><input type="text" name="mail" value="<? if(isset($_POST["mail"]) and $email=="ok" )
- {$_SESSION["mail"]=$_POST["mail"];
- echo @$_SESSION["mail"];}
- else
- {echo $null;}?>"></td>
- <td> </td>
- </tr>
- <tr>
- <td width="124" height="40"><img src="images/fleche.gif" height="10" width="9"> Téléphone:</td>
- <td><input name="tel" type="text" maxlength="10" value="<? if(isset($_POST["tel"]) and $num==0 and $tel==10)
- {$_SESSION["tel"]=$_POST["tel"];
- echo @$_SESSION["tel"];}
- else
- {echo $null;}?>"></td>
- <td> </td>
- </tr>
- <tr>
- <td width="124" height="40"><img src="images/fleche.gif" height="10" width="9"> Fax:</td>
- <td><input name="fax" type="text" maxlength="10" value="<? if(isset($_POST["fax"]) and $fax2==0 and $fax==10)
- {$_SESSION["fax"]=$_POST["fax"];
- echo @$_SESSION["fax"];}
- else
- {echo $null;}?>"></td>
- <td> </td>
- </tr>
- <tr>
- <td height="51" > </td>
- <td><input type="submit" value="valider"></td>
- </tr>
- </tbody>
- </table>
- </tr>
- <tr>
- <td align="center" valign="top" width="583"></td>
- </tr>
- </tbody>
- </table></td>
- <TD width="148"><? require($_SERVER["DOCUMENT_ROOT"]."/promo.php" ); ?></TD>
- </TR>
- <tr>
|
les critique sont ouvertes.. je sens que sa va faire mal...![[:aldark] [:aldark]](https://forum-images.hardware.fr/images/perso/aldark.gif) |