| 12
 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
 
 |  
//toute la partie formulaire et mise en forme de celui-ci
<div style="text-align: center;">
 
  <div id="Layer2" style="position:absolute; width:356px; height:697px; z-index:2; left: 363px; top: 133px;"> 
Veuillez entrer les données du nouveau contact à ajouter : 
    <form name="form1" method="post" action="" style="width: 382px;height: 410px;margin-left: auto;margin-right: auto;overflow: auto;"> 
      <table width="93%" height="695" BORDER=2 align="center" cellpadding="1" cellspacing="8" bordercolorlight="#0000CC" bordercolordark="#999999"  frame="box" class="contour" STYLE="border-width:8; border-style:ridge; align="center"; overflow="auto";>
        <tr> 
          <td width="37%" height="37" align="left" valign="middle"> 
            <p><font color="#FFFFFF" face="Comic Sans MS"><strong>Categorie : 
               </strong></font></p></td>
          <td width="67%" height="37" align="center" valign="middle"> 
            <div align="center"><strong> 
               <input type="text" name="category" style="width:190px" size="1" maxlength="34"/>              
              </strong></div></td>
        </tr>
        <tr> 
          <td width="37%" height="37" align="left" valign="middle"> <p align="left"><font color="#FFFFFF" face="Comic Sans MS"><strong>Nom : 
              </strong></font></p></td>
          <td width="67%" height="36" align="center" valign="middle"> <strong>
           <input type="text" name="nom" style="width:190px" size="1" maxlength="34"/> 
            </strong></td>
        </tr>
        <tr> 
          <td width="37%" height="37" align="left" valign="middle"> <p><font color="#FFFFFF" face="Comic Sans MS"><strong>Prenom :  
               </strong></font></p>
          </td>
          <td width="67%" height="36" align="center" valign="middle">
             <strong> 
                <input type="text" name="prenom" style="width:190px" size="1" maxlength="34"/> 
                </strong>
          </td>
        </tr>
        <tr> 
          <td width="37%" height="37" align="left" valign="middle"> <p><font color="#FFFFFF" face="Comic Sans MS"><strong>Adresse :  
               </strong></font></p>
          </td>
          <td width="67%" height="36" align="center" valign="middle">
             <strong> 
                <input type="text" name="adresse" style="width:190px" size="1" maxlength="34"/> 
                </strong>
          </td>
        </tr>
        <tr> 
          <td width="37%" height="37" align="left" valign="middle"> <p><font color="#FFFFFF" face="Comic Sans MS"><strong>code postal :  
               </strong></font></p>
          </td>
          <td width="67%" height="36" align="center" valign="middle">
             <strong> 
                <input type="text" name="code_postal" style="width:190px" size="1" maxlength="34"/> 
                </strong>
          </td>
        </tr>
        <tr> 
          <td width="37%" height="37" align="left" valign="middle"> <p><font color="#FFFFFF" face="Comic Sans MS"><strong>ville :  
               </strong></font></p>
          </td>
          <td width="67%" height="36" align="center" valign="middle">
             <strong> 
                <input type="text" name="ville" style="width:190px" size="1" maxlength="34"/> 
                </strong>
          </td>
        </tr>
        <tr> 
          <td width="37%" height="37" align="left" valign="middle"> <p><font color="#FFFFFF" face="Comic Sans MS"><strong>numero de telephone :  
               </strong></font></p>
          </td>
          <td width="67%" height="36" align="center" valign="middle">
             <strong> 
                <input type="text" name="num_tel" style="width:190px" size="1" maxlength="34"/> 
                </strong>
          </td>
        </tr>
       <tr> 
          <td width="37%" height="37" align="left" valign="middle"> <p><font color="#FFFFFF" face="Comic Sans MS"><strong>email :  
               </strong></font></p>
          </td>
          <td width="67%" height="36" align="center" valign="middle">
             <strong> 
                <input type="text" name="email" style="width:190px" size="1" maxlength="34"/> 
                </strong>
          </td>
        </tr>
        <tr align="center" valign="middle"> 
          <td height="61" colspan="2"> <div align="center"><font color="#FFFFFF" size="1" face="AComic Sans MS"><strong>
 
              <input name="submit" type="submit" value="ajouter le contact">
              </strong></font></div></td>
        </tr>
      </table>
 
    </form>
  </div>
</div>
</div>
// Partie php pour ajouter les données du contact a la base de donnée
<?php
 
//Inclusion du fichier contenant la connexion à la base
include_once('connexion-PDO.php');
 
 
$table="contact";
 
$category=""; 
if(!empty($_POST["category"]))
   $category=$_POST["category"];
 
$nom=""; 
if(!empty($_POST["nom"]))
   $nom=$_POST["nom"];
 
$prenom=""; 
if(!empty($_POST["prenom"]))
   $prenom=$_POST["prenom"];
 
 
$adresse=""; 
if(!empty($_POST["adresse"]))
   $adresse=$_POST["adresse"];
 
$code_postal=""; 
if(!empty($_POST["code_postal"]))
   $code_postal=$_POST["code_postal"];
 
$ville=""; 
if(!empty($_POST["ville"]))
   $ville=$_POST["ville"];
 
$num_tel=""; 
if(!empty($_POST["num_tel"]))
   $num_tel=$_POST["num_tel"];
 
$email=""; 
if(!empty($_POST["email"]))
   $email=$_POST["email"];
 
 
// Ajoute la nouvelle fiche
$query = "INSERT INTO $table(id, categorie, nom, prenom, adresse, code_postal, ville, num_tel, email)";
$query .= " VALUES('','$category','$nom','$prenom','$adresse','$code_postal','$ville','$num_tel','$email')"; 
 
$sth = $dbh->query($query);
 
if ($dbh) {
$dbh = NULL;}
?>
 
 
</body>
</html> | 
Partager