[object HTMLInputElement] ?
Hello guys
I already tried searching this in google.
But I really don't understood this error since I'm new to JQuery.
I hope someone here has kind heart and help me with this small problem.
Below are my codes,
index.php
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Submit form using Jquery to MySQL with PHP</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script src="jquery-1.4.2.js" type="text/javascript"></script>
<script src="jquery.js" type="text/javascript"></script>
</head>
<body>
<div class="container">
<form id="submit" method="post">
<fieldset>
<legend>Enter Information</legend>
<label for="org">To what organization?</label>
<input id="org" class="text" name="org" size="20" type="text"> <br>
<label for="date">When did you donated?</label>
<input id="date" class="text" name="date" size="20" type="text"> <br>
<label for="amount">Amount?</label>
<input id="amount" class="text" name="amount" size="20" type="text"> <br>
<label for="proof">Proof of receipt?</label>
<input id="proof" class="text" name="proof" size="20" type="text"> <br>
<button class="button positive">Add Client </button>
</fieldset>
</form>
<div class="success" style="display: none;">Client has been added.</div>
</div>
</body>
</html>
jquery.js
- $(document).ready(function(){
$("form#submit").submit(function() {
// we want to store the values from the form input box, then send via ajax below
var org = $('#org').attr('value');
var date = $('#date').attr('value');
var amount = $('#amount').attr('value');
var proof = $('#proof').attr('value');
$.ajax({
type: "POST",
url: "ajax.php",
data: "org="+ org +"&date="+ date +"&amount="+ amount +"&proof="+ proof,
success: function(){
$('form#submit').hide(function(){$('div.success').fadeIn();});
}
});
return false;
});
});
ajax.php
- <?php
include ("config.php");
// CLIENT INFORMATION
$username - '';
$org = htmlspecialchars(trim($_POST['org']));
$date = htmlspecialchars(trim($_POST['date']));
$amount = htmlspecialchars(trim($_POST['amount']));
$proof = htmlspecialchars(trim($_POST['proof']));
//Insert username dynamically from session
$addClient = "INSERT INTO orgs (username,org,date,amount,proof) VALUES ('$username','$org','$date','$amount','$proof')";
mysql_query($addClient) or die(mysql_error());
?>
The error is, everytime I insert a record in to database the value of the columns are these,
--> [object HTMLInputElement]
Thanks in advanced.