Created
October 12, 2017 18:50
-
-
Save yakutozcan/78d3b0f9d5bfdc03c60d5ebf9ead3827 to your computer and use it in GitHub Desktop.
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 | |
//MySQL veri tabanı ayarları | |
$servername = "localhost"; | |
$username = "root"; | |
$password = ""; | |
$dbname = "arduphp"; | |
if(isset($_GET['deger'])) | |
{ | |
$gelen = $_GET['deger']; | |
if(!empty($gelen)){ | |
try { | |
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password); | |
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | |
//Gelen veriyi kayıt ediyoruz | |
//http://yakut-macbook-air.local/arduphp.php?deger=yakut | |
$sql = "INSERT INTO TBL_Veriler (veriler, tarih) VALUES ('".$_GET["deger"]."', now())"; | |
$conn->exec($sql); | |
echo "ok:". $_GET['deger']; | |
//Kayıt gerçekleşir ise ok:yakut döndürecek | |
} | |
catch(PDOException $e) | |
{ | |
echo $sql . $e->getMessage(); | |
} | |
}else{ | |
echo "bos"; | |
} | |
}else{ | |
echo "merhaba"; | |
} | |
$conn = null; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment