I have a form where i want to submit multiple variables to a php script which inserts the data into my database. I tested the php script w/ arbitrary values and it works fine. When i go to retrieve the values via POST nothing comes up. This is what i have for the jquery: $("#form1").submit(function(){ dataString = $("#form1").serialize(); alert($(this).serialize()); $.ajax({ type: "POST", url: "scripts/addrating.php", data: dataString, dataType: "json", success: function(data) { alert('submitted'); } }); }); Code (markup): Here is my php code that is suppose to insert the data into my database: include_once('db_new.php'); function addRating() { $firstname = $_POST['fname']; $lastname = $_POST['lname']; $c = new DB(); $conn = $c->connectToMySQL(); $sql = "INSERT INTO coach (fname, lname) VALUES ('$firstname', 'lastname') "; $result=$c->queery($sql); if (!mysql_query($sql,$conn)) { die('Error: ' . mysql_error()); } echo "1 record added"; } addRating(); PHP: Any idea why the POST method is not retrieving variable values?
sorry for wasting your time. the $_POST['fname'] should of been $_POST['firstname']... damn variable names!