0

i just wanna make a simple sign up form and when blanks are empty and i click button i can see "Please Fill All Fields".But when i fill the blanks and click submit button nothing happens.i cant see "Form Submitted Succesfully" and any insert in to my table "hastalar".Pls help me.

http://www.eksiduyuru.com/files/1464/1464794851_1.jpg "undefined"

http://www.eksiduyuru.com/files/1464/1464794851.jpg "hastalar table"

script.js

$(document).ready(function(){
$("#submit").click(function(){

var name = $("#name").val();
var tc = $("#tc").val();
var password = $("#password").val();
var contact = $("#contact").val();
var dataString = 'name1='+ name + '&tc1='+ tc + '&password1='+ password + '&contact1='+ contact;

if(name==''||email=='   '||password==''||contact=='')
 {
 alert("Please Fill All Fields");
  }
  else
 {
 // AJAX Code To Submit Form.
 $.ajax({
 type: "POST",
 url: "ajaxsign.php",
 data: dataString,
 cache: false,
 success: function(result){
 alert(result);
  }
  });
  }
  return false;
  });
  });

ajaxsign.php

<?php include ("includes/db.php"); ?>
 <?php 

if(isset($_POST["submit"])){

 $name2=$_POST['name1'];
 $tc2=$_POST['tc1'];
 $password2=$_POST['password1'];
 $contact2=$_POST['contact1']; }
 //Insert query
 $query =mysql_query("insert into hastalar(adi, tc_no, password, tel)     values ('$name2', '$tc2', '$password2','$contact2')");
 if (!empty($name2) && !empty($tc2) && !empty($password2) && !empty($contact2) )
 {
  echo "Form Submitted Succesfully";
  }




  if(isset($connection)){


   mysql_close($connection);
   }

  ?>

db.php

   $connection=@mysql_connect("localhost","root","");

    if(!$connection){


    die("Veritabanı bağlantı hatası:".mysql_error());

    }


     $db=mysql_select_db("proje",$connection);

     if(!$db){

    die("Veritabanı tablo seçim hatası:".mysql_error());


    }

1 Answers1

0

script.js at line 8: syntax error. change vvar dataString to var dataString

.. ok edited my answer.

$(document).ready(function(){
$("#submit").click(function(){

var name = $("#name").val(),
    tc = $("#tc").val(),
    password = $("#password").val(),
    contact = $("#contact").val();

if(name==''||email=='   '||password==''||contact=='') {
    alert("Please Fill All Fields");
} else {
    // AJAX Code To Submit Form.
    $.ajax({
         type: "POST",
         url: "ajaxsign.php",
         data: {'name1':name,'tc1':tc,'password1':password,'contact1':contact},
         cache: false,
         success: function(result){
             alert(result);
         }
    });
  }
  return false;
 });
});
  • sorry mate it was paste error i fixed that.My main problem is i cant insert datas into my table and cant get answer "Form Submitted Succesfully". – Burak Halitoğlu Jun 01 '16 at 18:45