Created
April 29, 2020 09:29
-
-
Save prensmiskin/2775e7fe3040037e8e9e50fb6ab11157 to your computer and use it in GitHub Desktop.
Sahnarts APP / Tc No doğrulama için kullanılan web servis. https://tckimlik.nvi.gov.tr/Service/KPSPublic.asm -> ile çalışmaktadır.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if($_SERVER['REQUEST_METHOD']=='POST'){ | |
//$name = //$_POST["kisi_ad"]; | |
$nametwo = $_POST["kisi_adtwo"]; | |
$namethree = $_POST["kisi_adthree"]; | |
$mailx = "y"; | |
//$adx = $_POST["adx"]; | |
//$soyadx = $_POST["soyadx"]; | |
$adx = mb_strtoupper( $_POST["adx"],"UTF-8"); | |
$soyadx = mb_strtoupper( $_POST["soyadx"],"UTF-8"); | |
$dogumx = $_POST["dogumx"]; | |
$tcnox = $_POST["tcnox"]; | |
$maill = "y"; //$_POST["kisi_tel"]; | |
$passworda = $_POST["kisi_password"]; | |
$tc = $_POST["kisi_tc"]; | |
$code = rand(10000,100000); | |
$durum = 0; | |
$namex = $adx; | |
$soyadx = $soyadx; | |
$dogx = $dogumx; | |
$tcx = $tcnox; | |
$servername = "delete"; | |
$username = "delete"; | |
$password = "delete"; | |
$dbname = "delete"; | |
try { | |
$conn = new PDO("mysql:host=$servername;dbname=$dbname;charset=utf8", $username, $password); | |
// set the PDO error mode to exception | |
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | |
$v = $conn->prepare("select * from register where mail=? "); | |
$v->execute(array($maill)); | |
$x = $v->fetch(PDO::FETCH_ASSOC); | |
$d = $v->rowCount(); | |
if( $d){ | |
//$result["success"] = 2; | |
// echo json_encode($result); | |
function tcno_dogrula($bilgiler){ | |
$gonder = '<?xml version="1.0" encoding="utf-8"?> | |
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> | |
<soap:Body> | |
<TCKimlikNoDogrula xmlns="http://tckimlik.nvi.gov.tr/WS"> | |
<TCKimlikNo>'.$bilgiler["tcno"].'</TCKimlikNo> | |
<Ad>'.$bilgiler["isim"].'</Ad> | |
<Soyad>'.$bilgiler["soyisim"].'</Soyad> | |
<DogumYili>'.$bilgiler["dogumyili"].'</DogumYili> | |
</TCKimlikNoDogrula> | |
</soap:Body> | |
</soap:Envelope>'; | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, "https://tckimlik.nvi.gov.tr/Service/KPSPublic.asmx" ); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true ); | |
curl_setopt($ch, CURLOPT_POST, true ); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); | |
curl_setopt($ch, CURLOPT_HEADER, FALSE); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, $gonder); | |
curl_setopt($ch, CURLOPT_HTTPHEADER, array( | |
'POST /Service/KPSPublic.asmx HTTP/1.1', | |
'Host: tckimlik.nvi.gov.tr', | |
'Content-Type: text/xml; charset=utf-8', | |
'SOAPAction: "http://tckimlik.nvi.gov.tr/WS/TCKimlikNoDogrula"', | |
'Content-Length: '.strlen($gonder) | |
)); | |
$gelen = curl_exec($ch); | |
curl_close($ch); | |
return strip_tags($gelen); | |
} | |
$bilgiler = array( | |
"isim" => $namex, | |
"soyisim" => $soyadx, | |
"dogumyili" => $dogx, | |
"tcno" => $tcx | |
); | |
$sonuc = tcno_dogrula($bilgiler); | |
if($sonuc=="true"){ | |
//$result["success"] = 4; | |
// echo json_encode($result); | |
/* $sql = "INSERT INTO register (name,nametwo,yil,mail,password,code,durum) | |
VALUES ('$name','$nametwo', '$namethree','$maill','$passworda','$code','$durum')"; | |
// use exec() because no results are returned | |
$conn->exec($sql); | |
*/ | |
$sql = "UPDATE register SET tconay='2 ' WHERE mail='$mailx' "; | |
$stmt = $conn->prepare($sql); | |
// execute the query | |
$stmt->execute(); | |
if($stmt){ | |
$result["success"] = 15; | |
echo json_encode($result); | |
$statement = $conn->prepare("SELECT tconay FROM register WHERE mail ='$mailx'"); | |
$statement->execute(); | |
$arrayd = $statement->fetchAll(PDO::FETCH_ASSOC); | |
foreach($arrayd as $rty){ | |
$ee = $rty["tconay"]; | |
} | |
$tconayx = $ee; | |
$result["success"] = $tconayx; | |
echo json_encode($result); | |
}else{ | |
$result["success"] = "2222"; | |
echo json_encode($result); | |
} | |
} | |
else{ | |
$result["success"] = 12; | |
echo json_encode($result); | |
} | |
}else{ | |
}//DEĞİLSE | |
}//TRY | |
catch(PDOException $e) | |
{ | |
echo $sql . "<br>" . $e->getMessage(); | |
} | |
$conn = null; | |
}//POST | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment