Subversion Repositories Sites.obs-saisons.fr

Rev

Rev 5 | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?php

include("../connect.php");

      
$nom_station = $_GET['nom_station'];
$environnement_id = $_GET['environnement_id'];
$lat_station = $_GET['lat_station'];
$lon_station = $_GET['lon_station'];
$alt_station = $_GET['alt_station'];
$participant_id = $_GET['participant_id'];
$action = $_GET['action'];
$station_id = $_GET['station_id'];

if ($action=='C') { // Creation 

        // Insert new row with user data
        $query = sprintf("INSERT INTO STATION  " .
                 " (STATION_ID, PARTICIPANT_ID, STATION_NOM, STATION_LATITUDE, STATION_LONGITUDE, STATION_ALTITUDE, STATION_ENVIRONNEMENT_ID ) " .
                 " VALUES (NULL, '%s', '%s', '%s', '%s', '%s', '%s');",
                 mysql_real_escape_string($participant_id),
                 mysql_real_escape_string($nom_station),
                 mysql_real_escape_string($lat_station),
                 mysql_real_escape_string($lon_station),
                 mysql_real_escape_string($alt_station),
                 mysql_real_escape_string($environnement_id));
        
        $result = mysql_query($query);
        
        if (!$result) {
          die('Invalid query: ' . mysql_error());
        }
}
if ($action=='U') { // Mise a jour 

        // Update new row with user data
        $query = sprintf("UPDATE STATION  SET" .
                 " PARTICIPANT_ID='%s'," .
                 " STATION_NOM='%s'," .
                 " STATION_LATITUDE='%s'," .
                 " STATION_LONGITUDE='%s', " .
                 " STATION_ALTITUDE='%s'," .
                 " STATION_ENVIRONNEMENT_ID='%s' WHERE STATION_ID='%s'; ",
                 mysql_real_escape_string($participant_id),
                 mysql_real_escape_string($nom_station),
                 mysql_real_escape_string($lat_station),
                 mysql_real_escape_string($lon_station),
                 mysql_real_escape_string($alt_station),
                 mysql_real_escape_string($environnement_id),
                 mysql_real_escape_string($station_id));
        
        
        $result = mysql_query($query);
        
        if (!$result) {
          die('Invalid query: ' . mysql_error());
        }
}

if ($action=='D') { // Suppression 


        $query = sprintf("DELETE FROM STATION  " .
                         " WHERE STATION_ID='%s'; ",
                         mysql_real_escape_string($station_id));
        
        $result = mysql_query($query);
        
        if (!$result) {
          die('Invalid query: ' . mysql_error());
        }
}


?>