|
|
@@ -1,50 +0,0 @@
|
|
|
-<?php
|
|
|
-function connect(){
|
|
|
-
|
|
|
- $link = mysql_connect('localhost','mn','fernandoalonso') or die(mysql_error());
|
|
|
- mysql_select_db('MN', $link) or die(mysql_error());
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-function executeQuery($requete) {
|
|
|
- $resultat = mysql_query($requete) or die(mysql_error());
|
|
|
-
|
|
|
- if(substr($requete, 0, 6) === 'SELECT'){
|
|
|
- while($donnees=mysql_fetch_array($resultat)){
|
|
|
- $resultats[]=$donnees;
|
|
|
- }
|
|
|
- if (!isset($resultats)) {
|
|
|
- return null;
|
|
|
- }
|
|
|
- }
|
|
|
- else if(substr($requete, 0, 6) === 'INSERT'){
|
|
|
- $resultats = mysql_insert_id();
|
|
|
- }
|
|
|
- else {
|
|
|
- $resultats = 'ok';
|
|
|
- }
|
|
|
-
|
|
|
- return $resultats;
|
|
|
-}
|
|
|
-
|
|
|
-connect();
|
|
|
-
|
|
|
-if($_POST['query']) {
|
|
|
- $resultat = executeQuery($_POST['query']);
|
|
|
-}
|
|
|
-
|
|
|
-if($_POST['mail']) {
|
|
|
- // Pour envoyer un mail HTML, l'en-tête Content-type doit être défini
|
|
|
- $headers = 'MIME-Version: 1.0' . "\r\n";
|
|
|
- $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
|
|
|
-
|
|
|
- // En-têtes additionnels
|
|
|
- $headers .= 'From: Manche Numérique <francoisbeaufils@free.fr>' . "\r\n";
|
|
|
-
|
|
|
- // Envoi
|
|
|
- $to=$_POST['mail']['to'];
|
|
|
- mail($to, $_POST['mail']['sujet'], $_POST['mail']['message'], $headers);
|
|
|
-}
|
|
|
-
|
|
|
-echo json_encode($resultat);
|
|
|
-?>
|