index.html
<script src="http://code.jquery.com/jquery-1.10.0.min.js"></script>
<form method="post" class="form">
<div>
<input type="radio" name="anket" value="5" id="5">
<label for="Guzel">Guzel</label>
</div>
<div>
<input type="radio" name="anket" value="4" id="4">
<label for="Ýyi">Ýyi</label>
</div>
<div>
<input type="radio" name="anket" value="3" id="3">
<label for="Kotu">Kotu</label>
</div>
<button id="submit">Gonder</button>
</form>
<script type="text/javascript">
$(function(){
$( ".form" ).on( "click", function() {
var anketCevap = $( "input:checked" ).val();
$.ajax({
url:"annketoyla.php",
method: 'POST',
data: {cevap:anketCevap},
success: function(e) {
alert(e)
}
});
})
})
</script>
annketoyla.php
<?
$anketCevap = $_POST["cevap"];
echo $anketCevap. ' - Başarıyla eklendi';
/* $insert = mysql_query("insert into oy (cevap) VALUES ('$oy')");
if($insert){
echo "Anket başarı ile tamamlandı";
}else{
echo "Anket işlemi sırasında hata oluştu";
}*/
?>