0

I want design a login form via PHP + JQuery Ajax.

I have 2 textbox :

  • txtbox1 id="kadiID"
  • txtbox2 id="sifreID"

and button :

  • id="btnGiris"

My buttons JQuery code is:

$('#btnGiris').on("click", function(){ var kullaniciID=$("#kadiID").val(); var sifreID=$("#sifreID").val(); var cpthcID=''; if($('#kontrolID').length){ cpthcID=$('#kontrolID').val(); alert("cpthc: [" + cpthcID + "]"); } $.ajax({ type : "GET", url :'giris.php', data:({ kadi : kullaniciID, sifre : sifreID, cpthc : cpthcID }), cache:false, beforeSend :function() { // other codes }, success :function(donen_veri){ alert(donen_veri); }, complete:function() { // other code }, }) return false; }) 

When I click button, my send datas from javascript are not process in giris.php file. Also I opened development tool via F12 and open network tab then I click button I saw a url like this:

Datas which I send via ajax data field are apear in url:

enter image description here

How can I solve this.

3
  • you javascript is working fine. The data are sent to your php file. This part of your code works. But without the other side, we can't help Commented Oct 12, 2017 at 14:38
  • Can you please add the php part of the code? Commented Oct 12, 2017 at 15:10
  • Maybe you should post it: type : "POST", but without the php we won't know. Commented Oct 12, 2017 at 15:17

2 Answers 2

1

I just change

type: "POST"

instead of

type: "GET"

in my ajax code, and problem is solved, thanks for everyone, especially HMR

Sign up to request clarification or add additional context in comments.

Comments

0

this is my php code:

<?php ob_start(); error_reporting(E_ALL ^ E_NOTICE); session_start(); include '../ayar.php'; $tablo="kullaniciTB"; $durum=''; if(!isset($_SESSION["login"])){ if (!isset($_SESSION['count'])) { $_SESSION['count'] = 1; } else{ if (empty($_SESSION['count'])) { $_SESSION['count'] = 1; $durum='count: ' . $_SESSION['count']; } else { $_SESSION['count']++; } } $kadi = $_POST['kadi']; $sifre = $_POST['sifre']; if($kadi=='' or $sifre=='') { $yazi="xbosx"; } else if(strstr($kadi, '=') or strstr($kadi, '\'') or strstr($kadi, '--')){ $yazi="yhacky"; } else{ $cptDurum=""; if($_SESSION['count']>4){ $kntrl = $_POST['cpthc']; if($kntrl==''){ $cptDurum="bos"; } else if($kntrl==$_SESSION['sifre']){ $cptDurum="dogru"; } else if($kntrl!=$_SESSION['sifre']){ $cptDurum="yanlis"; } } if($cptBos=="dogru"){ $sorgu="SELECT * FROM `" . $tablo . "` WHERE kullaniciAdi='".$kadi."' AND sifre='".$sifre."' AND yetki=1"; if ($sonuc = mysqli_query($conn, $sorgu)) { /* fetch associative array */ while ($deger = mysqli_fetch_assoc($sonuc)) { $_SESSION["vaktiGeldi"] = time() + 5400; $_SESSION["login"] = true; $_SESSION["user"] = $kadi; $_SESSION["userID"] = $deger['id']; $durum="kdogruk"; } /* free sonuc set */ mysqli_free_result($sonuc); } } else if($cptDurum=="bos"){ $durum="cptBos"; } else if($cptDurum=="yanlis"){ $durum="cptYanlis"; } } } else{ $durum="mzatenm"; } echo $durum; 

?>

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.