insertClient.php 2.02 KB
Newer Older
1
<!DOCTYPE html>
Oswaldo Aldair Alanis Mayorga's avatar
Oswaldo Aldair Alanis Mayorga committed
2
<html>
3 4 5 6
  <head>
    <meta charset="utf-8">
    <title>Insert Client </title>
  </head>
Oswaldo Aldair Alanis Mayorga's avatar
Oswaldo Aldair Alanis Mayorga committed
7 8
  <body>
    <table border = "1">
9 10 11 12 13 14 15 16
      <tr>
        <th> nom </th>
        <th>prenom</th>
        <th> ddn </th>
        <th> adresse </th>
        <th> numero </th>
      </tr>
      <?php
17 18 19

        //include("connexion.php");

20 21 22
        $vHost = 'tuxa.sme.utc';
        $vPort = '5432';
        $vData = 'dbbdd0p020';
23
        $vUser = 'bdd0p020';
24
        $vPass = 'uLd6pAgM';
25 26 27 28 29 30

        $nom = $_POST['nom'];
        $prenom = $_POST['prenom'];
        $ddn = $_POST['ddn'];
        $add = $_POST['add'];
        $ntel = $_POST['ntel'];
31
        $vConn = new PDO("pgsql:host=$vHost;port=$vPort;dbname=$vData", $vUser, $vPass);
32 33 34 35 36 37 38 39 40 41 42 43 44
        if($nom)
        {
          if ($prenom)
          {
            if ($ddn)
            {
              if ($add)
              {
                if ($ntel)
                {

                  $vSql ="INSERT INTO Client (nom,prenom,ddn,adresse,numero) VALUES ( '$nom','$prenom','$ddn','$add','$ntel');";          	      $vSt = $vConn->prepare($vSql);
                  $vSt->execute();
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
                  $vSql ='SELECT * FROM client';
                  $vSt = $vConn->prepare($vSql);
                  $vSt->execute();

                  while ($vResult = $vSt->fetch(PDO::FETCH_ASSOC))
                  {
                    echo '<tr>';
        	          echo "<td>$vResult[nom]</td>";
        	          echo "<td>$vResult[prenom]</td>";
        	          echo "<td>$vResult[ddn]</td>";
        	          echo "<td>$vResult[adresse]</td>";
        	          echo "<td>$vResult[numero]</td>";
        	          echo '</tr>';
                  }

                }

              }
              else
               echo "Il faut de donner le numero de telephone";
            }
            else
             echo "Il faut de donner l'addresse";
          }
          else
           echo "Il faut de donner le prenom";
        }
        else
         echo "Il faut de donner le nom";
75
       ?>
Oswaldo Aldair Alanis Mayorga's avatar
Oswaldo Aldair Alanis Mayorga committed
76 77
    </table>

78

79 80
  </body>
</html>