forked from pipiscrew/fullcalendar-php-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate_user.php
42 lines (32 loc) · 908 Bytes
/
update_user.php
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
<?php
@session_start();
if (!isset($_SESSION["id"])) {
echo json_encode(1);
exit;
}
else {
date_default_timezone_set("UTC");
if ($_SESSION["login_expiration"] != date("Y-m-d"))
{
session_destroy();
echo json_encode(2);
exit;
}
}
if (!isset($_POST["user_id"]) || !isset($_POST["new_name"])) {
echo json_encode(3);
exit;
}
include 'config.php';
$db = connect();
$sql = "update users set user_mail=:user_mail where user_id=:user_id";
$stmt = $db->prepare($sql);
$stmt->bindValue(':user_mail' , $_POST['new_name']);
$stmt->bindValue(':user_id' , $_POST['user_id']);
$stmt->execute();
$res = $stmt->rowCount();
if($res == 1)
echo json_encode(100);
else
echo json_encode(0);
?>