-
Notifications
You must be signed in to change notification settings - Fork 0
/
restput.php
31 lines (28 loc) · 982 Bytes
/
restput.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
<?php
$nama = $_POST['nama'];
$nim = $_POST['nim'];
$prodi = $_POST['prodi'];
$ipk = $_POST['ipk'];
// {"nama":"jsjs","nim":"snnsjs","prodi":"bzbzjz","ipk":"nznznz"}
$senddata = array(
'nama' => $nama,
'nim' => $nim,
'prodi' => $prodi,
'ipk' => $ipk,
);
$data = json_encode( array( 'data' => $senddata ), JSON_FORCE_OBJECT );
$context = array(
'http' => array(
'method' => 'POST',
'header' => "Content-Length: " . strlen( $data ) . "\r\nContent-Type: application/json\r\n",
'content' => http_build_query($senddata)
)
);
$context = stream_context_create( $context );
$url = "http://localhost/kuliah/rest/putrest.php?mahasiswa_id=".$_GET['mahasiswa_id'];
$result = file_get_contents( $url, false, $context );
$response = json_decode($result, true);
var_dump($response);
if($response['status'] == '200')
header('Location: readrest.php');
?>