Skip to content

Instantly share code, notes, and snippets.

@yakutozcan
Created October 12, 2017 18:50
Show Gist options
  • Save yakutozcan/78d3b0f9d5bfdc03c60d5ebf9ead3827 to your computer and use it in GitHub Desktop.
Save yakutozcan/78d3b0f9d5bfdc03c60d5ebf9ead3827 to your computer and use it in GitHub Desktop.
<?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