Created
April 29, 2020 09:16
-
-
Save prensmiskin/b4925f096a443d0ff4ddb536d5f21eb5 to your computer and use it in GitHub Desktop.
Sahnarts APP / Kullanıcı profil resmini silme işlemini başlattığında çalışan web servis kodları. Şuan bu kodlar sunucu da ç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'){ | |
$mailx = $_POST["mailx"]; | |
$servername = "delete"; | |
$username = "delete"; | |
$password = "delete"; | |
$dbname = "delete"; | |
try { | |
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $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='$mailx' AND imagename=? "); | |
$v->execute(array('1')); | |
$x = $v->fetch(PDO::FETCH_ASSOC); | |
$d = $v->rowCount(); | |
if($d){ | |
$result["success"] = 44; | |
echo json_encode($result); | |
}else{ | |
$statement = $conn->prepare("SELECT imagename FROM register WHERE mail ='$mailx'"); | |
$statement->execute(); | |
$arrayd = $statement->fetchAll(PDO::FETCH_ASSOC); | |
foreach($arrayd as $rty){ | |
$ee = $rty["imagename"]; | |
} | |
$image_url = "imga/{$ee}"; | |
$dddg = realpath($image_url); | |
if (unlink($dddg)) { | |
$result["success"] = 8; | |
echo json_encode($result); | |
$sql = "UPDATE register SET imagename='1 ' WHERE mail='$mailx' "; | |
$stmt = $conn->prepare($sql); | |
// execute the query | |
$stmt->execute(); | |
if($stmt){ | |
$result["success"] = 15; | |
echo json_encode($result); | |
}else{ | |
$result["success"] = 25; | |
echo json_encode($result); | |
} | |
}else{ | |
$result["success"] = 9; | |
echo json_encode($result); | |
$dfsd = "1"; | |
$wdfswd = "1"; | |
} | |
//$result["imagename"] = $ee; | |
//echo json_encode($result); | |
//$dirs = scandir($dosya); | |
/* $sql = "INSERT INTO testred (code ) | |
VALUES ('$ee')" ; | |
// use exec() because no results are returned | |
$conn->exec($sql); | |
*/ | |
} | |
} | |
catch(PDOException $e) | |
{ | |
echo $sql . "<br>" . $e->getMessage(); | |
} | |
} | |
?> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment