<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
   <head>
        <title>Transfert SQL</title>
        <meta http-equiv="Pragma" content="no-cache" /> 
        <meta http-equiv="Cache-Control" content="no-cache, must-revalidate" />  
        <meta http-equiv="Expires" content="0" />
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    </head> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
        <body>
        <?php                           
        // bts2m.free.fr/Wifi/VI_modif.php?table=1&TitreM1=Temp_T1&TitreM2=Hum_H1&TitreM3=Pile_P1
        // roupet.free.fr/informatique/mysql.php
        
        //--Connexion au serveur
        define("NOM","tpil.projet");            //nom = login chez free
        define("PASSE","MotDePasse");          // passe=votre mot de passe free
        define("SERVEUR","sql.free.fr");     // adresse du serveur free
        $link = mysql_connect(SERVEUR,NOM,PASSE);
        $table='mesures';
        $titre='mesuresTitre';
        
        if(!$link) {echo"Impossible de se connecter au serveur".mysql_error();exit;}
                    else {echo "<h2>Connexion au serveur réussie !</h2>\n";}
        
            if (isset($_GET['table'])) {
            $table='mesures'.$_GET['table'];
            $titre='mesuresTitre'.$_GET['table'];
            echo "<p>Table : ".$table."  Titre : ".$titre."</p>\n";
            }
                
        mysql_select_db($titre,$link);
        
        if (isset($_GET['TitreM1'])) {
            $requete= "UPDATE ".$titre." SET titre ='".$_GET['TitreM1']."' WHERE id=1;";
            // echo $requete;
            $reponse=mysql_query($requete, $link); }
        if (isset($_GET['TitreM2'])) {
            $requete= "UPDATE ".$titre." SET titre ='".$_GET['TitreM2']."' WHERE id=2;";
            // echo $requete;
            $reponse=mysql_query($requete, $link); }
        if (isset($_GET['TitreM3'])) {
            $requete= "UPDATE ".$titre." SET titre ='".$_GET['TitreM3']."' WHERE id=3;";
            // echo $requete;
            $reponse=mysql_query($requete, $link); }
                    
        $requete= "SELECT * FROM ".$titre." ORDER BY `id` ASC";
        if ($reponse=mysql_query($requete, $link)) {
        $ligne=mysql_fetch_array($reponse, MYSQL_ASSOC);
        echo "<p> TitreM1=".$ligne[titre]."UnitM1=".$ligne[unit]."</p>\n";
        $ligne=mysql_fetch_array($reponse, MYSQL_ASSOC);
        echo "<p> TitreM2=".$ligne[titre]."UnitM2=".$ligne[unit]."</p>\n";
        $ligne=mysql_fetch_array($reponse, MYSQL_ASSOC);
        echo "<p> TitreM3=".$ligne[titre]."UnitM3=".$ligne[unit]."</p>\n";
        }
            
        mysql_close($link);
        ?>
    </body>
</html>