1 2 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
|
/*Connexion*/
if (!defined('SERVEUR')) {
define('SERVEUR', 'localhost');
}
if (!defined('UTILISATEUR')) {
define('UTILISATEUR', 'root');
}
if (!defined('MDP')) {
define('MDP', '');
}
if (!defined('DB')) {
define('DB', 'sondages');
}
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
try {
$conn = new mysqli(SERVEUR, UTILISATEUR, MDP, DB);
echo 'Connecté avec succès !';
} catch (Exception $e) {
echo 'ERROR:'.$e->getMessage();
}
/*********PROVISOIRE*************/
error_reporting(E_ALL);
ini_set('display_errors', true);
ini_set('display_startup_errors', true);
/*******************************/
function getIp()
{
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
return $ip;
}
require 'controller/dbConfig.php';
if (isset($_POST['valider'], $_POST['musique'], $_POST['paroles'], $_POST['voix'],$_POST['commentaire'], $_POST['heureValidation'])) {
$musique = htmlspecialchars($_POST['musique']);
$paroles = htmlspecialchars($_POST['paroles']);
$voix = htmlspecialchars($_POST['voix']);
$commentaire = htmlspecialchars($_POST['commentaire']);
$referer = $_SERVER['HTTP_REFERER'];
$navigateur = $_SERVER['HTTP_USER_AGENT'];
$heureValidation = htmlspecialchars($_POST['heureValidation']);
$adresse_IP = getIp();
} else {
echo 'Erreur 1 !';
}
// INSERTION VOTE
$sql1 = 'INSERT INTO je_fais_des_reves (musique, paroles, voix, commentaire, referer, navigateur, heureValidation, adresse_IP) VALUES (?,?,?,?,?,?,?,?)';
if ($stmt = $conn->prepare($sql1)) {
$stmt->bind_param('iiisssss', $musique, $paroles, $voix, $commentaire, $referer, $navigateur, $heureValidation, $adresse_IP);
$stmt->execute();
} else {
echo 'Erreur 2 !';
}
$stmt->close(); |
Partager