Add consultation module assets and libraries
This commit is contained in:
48
konsultasi/API/web/postPengaturan.php
Normal file
48
konsultasi/API/web/postPengaturan.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
include '../../conf/koneksiPDO.php';
|
||||
include '../../conf/function.php';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$conn = new createCon();
|
||||
$dbh = $conn->connect();
|
||||
|
||||
checkKey('POST', 'token');
|
||||
checkKey('POST', 'email');
|
||||
checkKey('POST', 'hp');
|
||||
|
||||
$token = trim($_POST['token']);
|
||||
$email = trim($_POST['email']);
|
||||
$hp = trim($_POST['hp']);
|
||||
|
||||
$sql = 'UPDATE mahasiswa SET email = :email, hp = :hp WHERE token = :token';
|
||||
$stmt = $dbh->prepare($sql);
|
||||
$stmt->bindParam(':token', $token);
|
||||
$stmt->bindParam(':email', $email);
|
||||
$stmt->bindParam(':hp', $hp);
|
||||
$stmt->execute();
|
||||
$error = $stmt->errorInfo();
|
||||
|
||||
$isError = true;
|
||||
|
||||
if ($error[0] == '00000') {
|
||||
$isError = false;
|
||||
}
|
||||
|
||||
if ($isError) {
|
||||
echo json_encode(
|
||||
array(
|
||||
'status' => 0,
|
||||
'msg' => 'Terjadi kesalahan teknis!!!',
|
||||
)
|
||||
);
|
||||
} else {
|
||||
echo json_encode(
|
||||
array(
|
||||
'status' => 1,
|
||||
'msg' => 'Berhasil mengubah data pribadi!!!',
|
||||
)
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user