Sunday, August 14, 2011

Process Two Submit Buttons on single Form for different actions

Working with multiple submit form is very useful idea to perform multiple action in single form. For example we can use this structure for Trial and Full Version download, Save and Save Draft,

	//Choose a File Based on Submit Button	
	if($_POST['download']=="Download Trail Version")
	elseif($_POST['download']=="Download Full Version")

	header('Content-type: application/octet-stream');
	header('Content-Disposition: filename="'.basename($file).'"');		
<!DOCTYPE html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>


<form id="form1" name="form1" method="post" action="<?=$_SERVER['PHP_SELF']?>">

<input type="submit" name="download" value="Download Trail Version" />
<input type="submit" name="download" value="Download Full Version" />


No comments:

Post a Comment