Created
August 23, 2017 07:15
-
-
Save senocak/53160569e62c64378a87d8de2c34b6bd to your computer and use it in GitHub Desktop.
PDO and verot.net class upload insert Contribution settings
This file contains hidden or 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 | |
public function ekle($sutun,$deger,$tablo,$resim,$dizin,$en,$boy){ | |
if($sutun!=""){ | |
$tablo_adlari=explode("--",$sutun); | |
$tablo_degerleri=explode("--",$deger); | |
$tablo_adlari_text=""; | |
$tablo_degerleri_text=""; | |
for($i=0;$i<count($tablo_adlari);$i++){ | |
$tablo_adlari_text.=$tablo_adlari[$i].','; | |
$tablo_degerleri_text.=":".$tablo_adlari[$i].","; | |
} | |
$tablo_adlari_text = rtrim($tablo_adlari_text, ","); | |
$tablo_degerleri_text = rtrim($tablo_degerleri_text, ","); | |
}else{ | |
$tablo_adlari_text=""; | |
$tablo_degerleri_text=""; | |
} | |
if($resim["name"]){ | |
if($dizin!=""){ | |
$dizin="/".$dizin; | |
} | |
require_once ('class.upload.php'); | |
$yukle = new upload($resim); | |
$klasor = '../images'.$dizin; | |
if ($yukle->uploaded){ | |
$yukle->image_resize = true; | |
$yukle->image_ratio_fill = true; | |
$yukle->image_x = $en; | |
$yukle->image_y = $boy; | |
if($tablo=="ayarlar"){ | |
$resim_tablo="logo"; | |
}else{ | |
$resim_tablo="resim"; | |
} | |
$yukle->file_new_name_body =$resim_tablo."_".rand(1000,9999); | |
$yukle->process($klasor); | |
if($yukle->processed) { | |
if($sutun!=""){ | |
$tablo_adlari_text=$tablo_adlari_text.",".$resim_tablo; | |
$tablo_degerleri_text=$tablo_degerleri_text.",:".$resim_tablo; | |
}else{ | |
$tablo_adlari_text=$tablo_adlari_text."".$resim_tablo; | |
$tablo_degerleri_text=$tablo_degerleri_text.":".$resim_tablo; | |
} | |
$stmt = $this->db->prepare("INSERT INTO $tablo($tablo_adlari_text) VALUES ($tablo_degerleri_text)"); | |
for($i=0;$i<count($tablo_degerleri);$i++){ | |
$stmt->bindParam(':'.$tablo_adlari[$i], $tablo_degerleri[$i], PDO::PARAM_STR); | |
} | |
$stmt->bindParam(':'.$resim_tablo, $yukle->file_dst_name, PDO::PARAM_STR); | |
$insert =$stmt->execute(); | |
if ($insert){ | |
echo '<script>alert("Eklenme Başarılı.");</script>'; | |
} | |
}else{ | |
echo '<script>alert("Düzenleme Başarısız.'.$yukle->error().'");</script>'; | |
} | |
echo "<script language='javascript'>location.href='index.php?sayfa=".$tablo."';</script>"; | |
} | |
}else{ | |
$stmt = $this->db->prepare("INSERT INTO $tablo($tablo_adlari_text) VALUES ($tablo_degerleri_text)"); | |
for($i=0;$i<count($tablo_degerleri);$i++){ | |
$stmt->bindParam(':'.$tablo_adlari[$i], $tablo_degerleri[$i], PDO::PARAM_STR); | |
echo ':'.$tablo_adlari[$i].",".$tablo_degerleri[$i]."<br>"; | |
} | |
$insert =$stmt->execute(); | |
if ($insert){ | |
echo '<script>alert("Eklenme Başarılı.");</script>'; | |
echo "<script language='javascript'>location.href='index.php?sayfa=".$tablo."';</script>"; | |
} | |
} | |
} |
Author
senocak
commented
Aug 23, 2017
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment