projetphp/post.php

41 lines
1.8 KiB
PHP
Raw Normal View History

2018-12-30 17:41:15 +01:00
<?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"]))
2018-12-30 19:53:28 +01:00
if(htmlspecialchars($_POST["updatePW"], ENT_QUOTES, 'UTF-8') == "true")
2018-12-30 17:41:15 +01:00
{
$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(
2018-12-30 19:53:28 +01:00
'datene' => htmlspecialchars($_POST["datene"], ENT_QUOTES, 'UTF-8'),
'email' => htmlspecialchars($_POST["email"], ENT_QUOTES, 'UTF-8'),
'pw' => md5(htmlspecialchars($_POST["pw"], ENT_QUOTES, 'UTF-8')),
'sl' => htmlspecialchars($_POST["sl"], ENT_QUOTES, 'UTF-8'),
'login' => htmlspecialchars($_POST["login"], ENT_QUOTES, 'UTF-8'),
2018-12-30 17:41:15 +01:00
));
$ret["return"] = true;
2018-12-30 19:53:28 +01:00
$ret["pw"] = md5(htmlspecialchars($_POST["pw"], ENT_QUOTES, 'UTF-8'));
2018-12-30 17:41:15 +01:00
}
else
{
$req = $bdd->prepare('UPDATE `projetphp` SET `date_naissance` = :datene, `e_mail` = :email, `security_level` = :sl WHERE `projetphp`.`login` = :login');
$req->execute(array(
2018-12-30 19:53:28 +01:00
'datene' => htmlspecialchars($_POST["datene"], ENT_QUOTES, 'UTF-8'),
'email' => htmlspecialchars($_POST["email"], ENT_QUOTES, 'UTF-8'),
'sl' => htmlspecialchars($_POST["sl"], ENT_QUOTES, 'UTF-8'),
'login' => htmlspecialchars($_POST["login"], ENT_QUOTES, 'UTF-8'),
2018-12-30 17:41:15 +01:00
));
$ret["return"] = true;
2018-12-30 19:53:28 +01:00
$ret["pw"] = htmlspecialchars($_POST["pw"], ENT_QUOTES, 'UTF-8');
2018-12-30 17:41:15 +01:00
}
else;
echo json_encode((object)$ret);
?>