projetphp/post.php

41 lines
1.4 KiB
PHP

<?php
$ret["return"] = false;
$ret["pw"] = null;
try {
$config = include('config.php');
$bdd = new PDO('mysql:host='.$config['host'].';dbname='.$config['dbName'].';charset=utf8', $config['username'], $config['pw']);
} catch (Exception $e) {
die('Erreur : '.$e->getMessage());
}
//UPDATE `projetphp` SET `security_level` = '6' WHERE `projetphp`.`login` = 'aaazzze';
if(isset($_POST["updatePW"], $_POST["datene"], $_POST["email"], $_POST["pw"], $_POST["sl"], $_POST["login"]))
if($_POST["updatePW"] == "true")
{
$req = $bdd->prepare('UPDATE `projetphp` SET `date_naissance` = :datene, `e_mail` = :email, `mot_de_passe` = :pw, `security_level` = :sl WHERE `projetphp`.`login` = :login');
$req->execute(array(
'datene' => $_POST["datene"],
'email' => $_POST["email"],
'pw' => md5($_POST["pw"]),
'sl' => $_POST["sl"],
'login' => $_POST["login"],
));
$ret["return"] = true;
$ret["pw"] = md5($_POST["pw"]);
}
else
{
$req = $bdd->prepare('UPDATE `projetphp` SET `date_naissance` = :datene, `e_mail` = :email, `security_level` = :sl WHERE `projetphp`.`login` = :login');
$req->execute(array(
'datene' => $_POST["datene"],
'email' => $_POST["email"],
'sl' => $_POST["sl"],
'login' => $_POST["login"],
));
$ret["return"] = true;
$ret["pw"] = $_POST["pw"];
}
else;
echo json_encode((object)$ret);
?>