Ajax form and includes
Ajax form and includes
I've got a suggestion form that inserts into a db table when they submit, my jquery is located in a /js folder, while this page is in /, and my db settings are in /includes/
Here is my $.post
-
$.post("../sendsuggest.php",
{ subject: subjectVal, message: messageVal, theusername: theUser },
function(data){
$("#sendSuggestion").slideUp("normal", function() {
$("#sendSuggestion").before('<h1>Success</h1><p>Thank you for your comments!</p>');
});
}
);
sendsuggest.php is something like this
-
if(isset($_POST['submit'])) {
$theuser = $_POST['theusername'];
$subject = $_POST['subject'];
$message = $_POST['message'];
include("includes/database.inc");
connect_to_cms();
$sql = mysql_query("INSERT INTO suggestions(user,message,subject) VALUES('$theuser', '$message', '$subject')");
}
On my page, the slideUp works and this line: $("#sendSuggestion").before('<h1>Success</h1><p>Thank you for your comments!</p>');
works as well, but I can't figure out why it isn't inserting into the db. Any hints?