For some reason this ajax call sends data to the php file fine, and the MYSQL call works, but the php does not return anything to the ajax. I'm not sure if it's an issue with the ajax call or the php (I suspect the former). Could it have something to do with var 'data'? Is it the 'return false'? Or have I just stared at for too long and am missing something extremely simple?
It's weird because I've written this type of call a hundred times. Any help would be appreciated.
The jQuery:
$("#registration").submit(function (){
var newun = $("#newusername").val();
var newpass = $("#pass1").val();
var email = $("#email").val();
var sques = $("#secquestion").val();
var sans = $("#secanswer").val();
$.ajax ({
url: "include/registerfinalize.php",
data: {"newun": newun,
"newpass": newpass,
"email": email,
"sques": sques,
"sans": sans},
success: function (data){
alert(data)
}
})
return false
})
The PHP (simplified - it'll do more later):
<?php
include("../../bin/cxn.inc");
$cxn = mysqli_connect($host, $user, $pw, $db) or die ("Connection failed.");
$newuser = mysqli_real_escape_string($cxn, $_GET['newun']);
$newpass = mysqli_real_escape_string($cxn, $_GET['newpass']);
$email = mysqli_real_escape_string($cxn, $_GET['email']);
$sques = mysqli_real_escape_string($cxn, $_GET['sques']);
$sans = mysqli_real_escape_string($cxn, $_GET['sans']);
$query = "INSERT INTO whatever (username, password, blurb, achievements, sequence, favorites, remember, email, secquestion, secanswer) VALUES ('$newuser', '$newpass', '', '', '', '', '', '$email', '$sques', '$sans')";
$result = mysqli_query($cxn, $query) or die("database connection error");
echo "1";
mysqli_free_results($cxn);
mysqli_close($cxn);
?>