<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script>
<script type="text/javascript" >
$(function() {
$(".submit").click(function() {
var np = $("#np").val();
$.ajax({
type: "POST",
url: "inc/ajax.php",
data: np,
success: function(){
$('.success').fadeIn(200).show();
$('.error').fadeOut(200).hide();
}
});
}
return false;
});
</script>
I then have the following in ajax.php and I am 100% certain it's in the correct directory.
<?php
/**
* @author Shannon
* @copyright 2011
*/
session_start();
include ("connect.php");
$user = $_SESSION['username'];
$np = $_POST['np'];
$np = mysql_real_escape_string($np);
mysql_query("INSERT INTO `posts` (user, np) VALUES ('$user', '$np')") or die(mysql_error());
?>
That is all correct too, but it just doesn't seem to insert into the database. If anyone has an idea why, please post a reply.







