Location: PHPKode > scripts > AskPeople-Free PHP survey application > AskPeople_2_2_2/launch.php
<?php

session_start();

require_once('includes/config.inc.php');
require_once('includes/functions.inc.php');

require_once('login.inc.php');


switch ($_REQUEST['action']) { // questionnaire to be saved

	case "ShowCode" :

		include('includes/header.php');
		
        $directory = (substr(dirname($_SERVER['PHP_SELF']),-1) == "/") ? dirname($_SERVER['PHP_SELF']) : dirname($_SERVER['PHP_SELF']) . "/";
		$surveylink = $protocol . $_SERVER['HTTP_HOST'] . $directory . "survey.php?sid=".$_SESSION['admin_sid'];
		$code = "<!-- START OF EMBEDDED ASKPEOPLE SURVEY -->\n<iframe src=\"$surveylink&embed=true\" style='height:600px;width:100%;margin:0;padding:0;' frameborder='0' title=\"AskPeople survey: {$_SESSION['admin_stitle']}\" longdesc=\"This is a link to a survey titled: {$_SESSION['admin_stitle']}\">\n\tTo complete this survey, please visit:\r\t\t<a href=\"$surveylink\">\r\t\t\t$surveylink\r\t\t</a>\n</iframe>\n<!-- END OF EMBEDDED ASKPEOPLE SURVEY -->\n";
		
		$outputform = "
			<p id='surveylink'><img src=\"images/icons/web_16x16.gif\" width=\"16\" height=\"16\" class='icon' alt=\"Link to survey\" border=\"0\" />The link to this survey is: <a href='{$surveylink}'>{$surveylink}</a></p>
		  <div class='clearbox'>
			<h2>Sending the link to an email list</h2>
			<p>To invite people to participate in your survey, you can just include the link to this survey within a regular email:</p>
			<div class='clearbox'>
			  <pre>Hi everyone,
				  
Please take a minute to fill in my survey:
				  
<a href=\"$surveylink\">$surveylink</a>
				  
Thanks very much!</pre>
			</div>
			<p>You can also add a unique <code>&uid=User123</code> ID to each link, to help you record which of your contacts have responded. See the <a href='http://www.askpeople.co.uk/help/'>Help documentation' Tips &amp; Tricks</a> for more guidance on how to do this.</p>
	
			<h2>Using an &lt;iframe&gt;</h2>
			<p>Inline frames let you embed one web page within another, and are probably the easiest way to include your AskPeople survey within a regular webpage (see <a href='http://www.askpeople.co.uk/samples/iframe.html' target='_blank'>an example form</a>). You can copy and paste the piece of HTML code below into your own web page wherever you want this survey to appear:</p>
			<div id=\"codeexamplebox\" class=\"clearbox\" style='width:95%;'>
				<textarea cols=\"80\" rows=\"12\" name=\"codeexample\">$code</textarea></p>
				<p style=\"text-align:center;\"><a href=\"launch.php?action=DownloadCode\">Download this code</a></p>
			</div>

			<p>There are other ways to integrate AskPeople surveys with your site.</p><ul>
			<li>You can create your own template in the <a href='templatemgr.php?action=EditTemplate&templatename=AskPeopleDefault.php'>Template Manager</a>, making sure that you have the [SURVEYLINK] tag in the template where you want the survey form to be displayed.</li>
			<li>Alternatively, for a simple one-page form, you might choose to use a server-side include (if your web server supports them) or AJAX-based import.</li>
			</ul>
			<p>For more examples and techniques, check the Tips section of the <a href='http://www.askpeople.co.uk/forum'>AskPeople Forum</a>.</p>
		  
		  </div>
		";

	  break;
	
	case "DownloadCode" :
	
        $directory = (substr(dirname($_SERVER['PHP_SELF']),-1) == "/") ? dirname($_SERVER['PHP_SELF']) : dirname($_SERVER['PHP_SELF']) . "/";
		$surveylink = $protocol . $_SERVER['HTTP_HOST'] . $directory . "survey.php?sid=".$_SESSION['admin_sid'];
		$code = "<!-- START OF EMBEDDED ASKPEOPLE SURVEY -->\n<iframe src=\"$surveylink&embed=true\" style='height:600px;width:100%;margin:0;padding:0;' frameborder='0' title=\"AskPeople survey: {$_SESSION['admin_stitle']}\" longdesc=\"This is a link to a survey titled: {$_SESSION['admin_stitle']}\">\n\tTo complete this survey, please visit:\r\t\t<a href=\"$surveylink\">\r\t\t\t$surveylink\r\t\t</a>\n</iframe>\n<!-- END OF EMBEDDED ASKPEOPLE SURVEY -->\n";

		$nicefilename = "embedded_".$_SESSION['admin_sid'].".html";

		header("Content-Type: text/plain");
		// a load of extra headers here so IE doesn't choke on the file...
		header("Pragma: public");
		header("Expires: 0"); // set expiration time
		header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
		// define filename for download as export.txt
		header("Content-Disposition: attachment; filename=\"".$nicefilename."\"");
		
		echo ($code);
		exit();
	
	  break;

	default :

		header("Location: launch.php?action=ShowCode"); // default to form editor
		
	  break;

}

echo ($outputform);

include('includes/footer.php');

?>
Return current item: AskPeople-Free PHP survey application