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
https://forums.phpfreaks.com/topic/121297-form-with-ajax-and-phpmysql/
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>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.