Jump to content

Form with Ajax and PHP/MYSQL


nitation

Recommended Posts

Can anyone help me out regarding this big one. I want a user to click on a link/button and beneath the link/button, an input box should display with a submit button. When the user click on submit, it should insert to mysql table. This I guess is Ajax and PHP/MYSQL. I am using AJAX because i don't want the page to reload. But i don't seem to get them right

 

Thanks in Advance

Link to comment
Share on other sites

What data is being inserted into the MySQL table? Without that information, the best I can do is this:

 

<html>
<head><title>blah</title></head>
<body>

<a href='javascript:void(0);' onclick='displaySubmit();'>Show Submit Button</a><br />
<input type='button' id='tehbutton' value='submit' onclick='doSubmit();' style='display:none;' />

<script>
function displaySubmit() { document.getElementById("tehbutton").style.display = "block"; }
function doSubmit() {
var AJAX;
try { AJAX = new XMLHttpRequest(); } 
catch (e) {
	try { AJAX = new XDomainRequest(); } // for the upcoming IE 8.
	catch (e) {
		try { AJAX = new ActiveXObject("Microsoft.XMLHTTP"); } 
		catch (e) {
			try { AJAX = new ActiveXObject("Msxml2.XMLHTTP"); }
			catch (e) { AJAX = null; }
		}
	}
}
if (AJAX === null) alert("Your browser doesn't support AJAX");
else {
	AJAX.open("GET", "", true);
	AJAX.onreadystatechange = function() {
		if (AJAX.readyState == 4) {
			// do something
		}
	}
	AJAX.send("");
}
}
</script>

</body>
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.