-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathweb_curl.php
More file actions
27 lines (21 loc) · 827 Bytes
/
web_curl.php
File metadata and controls
27 lines (21 loc) · 827 Bytes
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
<?php
//Json İle Web Servis Yapımı (Post)
require_once ("baglan.php");
$token = $_POST["token"];
$ogrenci = intval($_POST["id"]);
if ($token != sha1(md5("mehmet"))) {die("Yetkisiz Erişim!");}
$ogrenciler = array();
if ($ogrenci>0) {
$sorgu = $baglan->query("select * from ogrenci where id='$ogrenci'", PDO::FETCH_ASSOC);
} else {
$sorgu = $baglan->query("select * from ogrenci", PDO::FETCH_ASSOC);
}
if ($sorgu->rowCount()>0) {
foreach ($sorgu as $satir) {
$ogrenciler[] = array("adsoyad" => $satir["adsoyad"], "tckimlik" => $satir["tckimlik"], "adres" => $satir["adres"]);
}
header("Cntent-Type:application/json; charset=utf-8");
$json = json_encode($ogrenciler, JSON_UNESCAPED_UNICODE);
echo $json;
}
?>