is it possible to submit a page without using a form

Recommended Answers

All 2 Replies

I think so...

You make onSubmit() in your submit button...
or
You can use an onclick and use the form.submit() function though.

This is for checking submit button is working or not..


if(@$_POST)
{


or
or
try using header("location:abc.php?username=xyz");

You have to make your header() calls before your script outputs anything.


Thanks
Shanti..

There are two ways that I know of and that is ajax with javascript and Curl with PHP.
Ajax has recently gotten a lot of attention and here is some sample code:

Ajax object:(do not modify)

//the ajax object for all ajax functions
function ajaxObject()
{
	var objectsuccess = true;
	var xmlHttp;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				objectsuccess = false;
			}
		}
	}
	
	if(objectsuccess == false)
	{
		alert("Your browser does not support AJAX!");
		return false;
	}
	else
	{
		return xmlHttp;
	}
}

Ajax post function:(do not modify)

/*postVars example
variable1=value&variable2=value&variable3=value&variable4=value
*/
function triggerPost(postVars, url)
{
	var xmlHttp = ajaxObject();
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			return xmlHttp.responseText;
		}
	}
	
	xmlHttp.open("POST",url,true);
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
	xmlHttp.send(postVars);
	return xmlHttp;
}

Your event function:(modify to fit your needs)

function ajaxlogin()
{
	//generate variables in query string format leaving out the innitial "?"
	var postVars = "";
	
	//the script you want to post to ex. forms/submitform.php
	var url = "";
	
	var xmlHttp = triggerPost(postVars, url);
	
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			var formOutPut = xmlHttp.responseText;
			//process the form response
		}
	}
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.