Created
December 30, 2012 08:39
-
-
Save eftalyurtseven/4411653 to your computer and use it in GitHub Desktop.
jQuery PHP AJAX Post Etme kodlarımız
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
<!DOCTYPE HTML> | |
<html lang="en-US"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Post işlemi » Eftal Yurtseven</title> | |
<link rel="stylesheet" href="style.css"/> | |
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.min.js"></script> | |
<script type="text/javascript"> | |
$(function(){ | |
$("#sonuc").hide(); | |
/* jQuery İşlemlerim */ | |
$(".gonder").click(function(){ | |
/* Post Degerleri Alınsın */ | |
var value = $(".input").val(); | |
// var deneme = "ad="+ad+"&soyad="+soyad+"yas="+yas; | |
if(!value){ | |
alert("Boş Alan Bıraktın"); | |
}else{ | |
$.ajax({ | |
type: "POST", | |
url: "post.ajax.php", | |
data: "deger="+value, | |
success: function(x){ | |
if(x == "bos"){ | |
$("#sonuc").fadeIn(200).addClass("hata").html(""); | |
$("#sonuc").html("<b>Boş Alanlar var!</b>"); | |
}else if(x == "yok"){ | |
$("#sonuc").fadeIn(200).addClass("hata").html(""); | |
$("#sonuc").html("<b>İşlem Başarısız!</b>"); | |
}else{ | |
$("#sonuc").fadeIn(200).addClass("ok").html(""); | |
$("#sonuc").html("<b>İşlem Tamam!</b>"); | |
} | |
} | |
}); | |
} | |
}); | |
}); | |
</script> | |
</head> | |
<body> | |
<!-- Ortala --> | |
<div id="center"> | |
<input type="text" name="value" class="input"/><br /> | |
<input type="submit" value="Gönder" class="gonder"/> | |
<div id="sonuc"></div> | |
</div> | |
<!--#Ortala --> | |
</body> | |
</html> |
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 | |
/* | |
* Author: Eftal Yurtseven | |
* URI: http://www.eftalyurtseven.com | |
*/ | |
/* | |
* Mysql Connx | |
*/ | |
$connx = mysql_connect("localhost", "root"); | |
if($connx){ | |
$dbConnx = mysql_select_db("test", $connx); | |
mysql_query("SET NAMES utf8"); | |
mysql_query("SET CHARACHTER SET UTF-8"); | |
}else{ | |
die("Veritabanına Bağlanılamadı"); | |
} | |
/* ************** ************ ******** */ | |
/* | |
* Veri Alımı ve Mysql Ekleme | |
*/ | |
$deger = mysql_real_escape_string(strip_tags(rtrim($_POST['deger']))); | |
if(!$deger){ | |
echo 'bos'; | |
}else{ | |
$ekle = mysql_query("INSERT INTO deger SET | |
deger = '$deger' | |
"); | |
if($ekle){ | |
echo 'ok'; | |
}else{ | |
echo 'yok'; | |
} | |
} | |
?> |
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
/* | |
* Eftal Yurtseven | |
*/ | |
body{margin: 0; padding: 0; background: #fff; font: 12px Segoe UI} | |
*{margin: 0; padding: 0; list-style-type: none; border: 0} | |
#center{width: 450px; padding: 7px; background: #eee; border: 1px solid #ddd; margin: 50px auto;} | |
.input{width: 400px; padding: 7px; background: #f1f1f1; border: 1px solid #ddd; margin: 10px} | |
.gonder{padding: 5px 8px; background: #333; margin: 10px; cursor: pointer; font: bold 14px Arial; color: #fff} | |
#sonuc{padding: 7px; background: #ddd; border: 1px solid #bbb; color: #000;} | |
.hata{background: red; color: #fff} | |
.ok{background: green; color: #fff} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
çalışmıyor