View Single Post
Old 04-02-2007, 11:41 PM   PM User | #1
tribalmaniac
Regular Coder

 
Join Date: Sep 2006
Posts: 122
Thanks: 4
Thanked 2 Times in 2 Posts
tribalmaniac is an unknown quantity at this point
Send comment to mysql database

For some reason i just cannot get this to work, the user enters a comment and it sends it to the database - I was getting so stressed that I just made the script send a straight forward line to the database -
Code:
var params = "comm=hello&subject=binny";
rather than what's in the text box, so ignore that!
Here's what i have so far

Code:
<script>
function newComment()
{
var url = "leavecomment.php";
var params = "comm=hello&subject=binny";
http.open("POST", url, true);

//Send the proper header information along with the request
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.setRequestHeader("Content-length", params.length);
http.setRequestHeader("Connection", "close");

http.onreadystatechange = function() {//Call a function when the state changes.
	if(http.readyState == 4 && http.status == 200) {
		alert(http.responseText);
	}
}
http.send(params);
}

</script>

</head>

<body>
<div>
<form name="test" >
<textarea id="comment" cols="30" rows="8"></textarea>
<input type="button" onClick="newComment()" value="Test"/>
</form>
tribalmaniac is offline   Reply With Quote