I was working with jQuery in the front end and php in the backend. I had some cross origin problem which I have fixed. but now I am filling up forms (sign up) but db is getting updated, not even empty row. Before I was getting some empty row in db ( I am sure about that, my memory is little hazy about that day! sorry!! ) I am unable to find any problem as errors or success message are not getting hit in jQuery file. I tried http://localhost/signup.php and its showing success message upon connecting to db. So I am sure that its connected to the proper db. I also tried to manual input using that php and i was able to import data as well.
I am adding the jQuery and php code below. I am using all this in XAMPP. Thanks in advance. :)
jQuery:
$("#userReg_btn").click(function(e)
{
//user registration in
var array = [];
var flag = false;
var fullName = $("#uFn").val();
var email = $("#uEa").val();
var mobile = $("#uMn").val();
var nID = $("#uNm").val();
var zip = $("#uZc").val();
var prof = $("#uPc").val();
array.push(fullName);
array.push(email);
array.push(mobile);
array.push(nID);
array.push(zip);
array.push(prof);
alert(array);
console.log(array);
$.ajax({
url:"http://localhost/signup.php",
data:
{
fullName: array[0],
email: array[1],
mobile: array[2],
nID: array[3],
zip: array[4],
prof: array[5],
},
type:"POST",
dataType:"json",
success:function(e){
alert("in success");
alert(e);
console.log("success");
},
error:function(e)
{
alert("error is hit");
alert(e);
console.log(e);
}
});
});
and php file:
<?php
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 01 Jan 2016 00:00:00 GMT');
header('Content-type: application/json');
$con=mysql_connect("localhost","root", "");
mysql_select_db("tester",$con);
$name = $_GET['fullName'];
$email= $_GET['email'];
$mobile= $_GET['mobile'];
$nID = $_GET['nID'];
$zip = $_GET['zip'];
$prof= $_GET['prof'];
$query="INSERT INTO user_reg(fullName,email,mobile,nID,zip,prof) VALUES('$name','$email', '$mobile','$nID','$zip','$prof');";
echo $name;
if(mysql_query($query))
{
echo "success";
}else{
echo mysql_error();
}
//}
?>
Thanks in advance again :)