Reputation: 39
I am using bootstrap 3.2.0 and jQuery. I can't get fetch data via jQuery and PhP
function postolayi(){
$.ajax({
type:'POST',
url:'giriskontrol.php',
data:$('#girisForm').serialize(),
success:function(cevap){
$("#uyari").html(cevap)
}
})
}
index.php
<form class="form-signin" method="POST" id="girisForm">
<input id="isim" name="isim" type="text" class="form-control" placeholder="isim" required autofocus>
<input name="sifre" type="password" class="form-control" placeholder="şifre" id="sifre" required>
<button class="btn btn-lg btn-primary btn-block" type="submit" onclick="postolayi();">
Giriş Yap</button>
</form>
<div class="alert alert-warning" id="uyari"></div>
giriskontrol.php
<?php
$POST["isim"] = $isim;
echo $isim;
?>
I can't fetch data. Please somebody help.
I changed as
<?php
$isim = $POST["isim"];
echo $isim;
?>
But still not working.
Upvotes: 0
Views: 79
Reputation: 344
You need to switch your assignment on your php page to
<?php
$isim = $_POST["isim"];
echo $isim;
?>
Upvotes: 0
Reputation: 15783
You are overwriting the post variable here:
$_POST["isim"] = $isim;
What you probably wanted was:
$isim = $_POST["isim"];
echo $isim;
Upvotes: 1
Reputation: 4157
In your php file Switch:
$POST["isim"] = $isim;
with
$isim = $POST["isim"];
Upvotes: 0