Location: PHPKode > projects > JaxBlog > JaxBlog/module/JaxForm/example.php
<?php

$request = isset($_GET['request']) ? $_GET['request'] : '';

if ($request == 'xml') {
	header('Content-Type: text/xml');
	echo '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
	
	$xml = "";
	$xml .= "<root>\n";
	
	$xml .= "	<controls_input>\n";
	$xml .= "		<record>\n";
	$xml .= "			<key>first_name</key>\n";
	$xml .= "			<value>Daniel</value>\n";
	$xml .= "		</record>\n";
	$xml .= "		<record>\n";
	$xml .= "			<key>last_name</key>\n";
	$xml .= "			<value>Juliano</value>\n";
	$xml .= "		</record>\n";
	$xml .= "		<record>\n";
	$xml .= "			<key>sex</key>\n";
	$xml .= "			<value>M</value>\n";
	$xml .= "		</record>\n";
	$xml .= "		<record>\n";
	$xml .= "			<key>hobby_games</key>\n";
	$xml .= "			<value>Y</value>\n";
	$xml .= "		</record>\n";
	$xml .= "		<record>\n";
	$xml .= "			<key>date_of_birth</key>\n";
	$xml .= "			<value>2007-09-20</value>\n";
	$xml .= "		</record>\n";
	$xml .= "	</controls_input>\n";
	
	$xml .= "	<controls_select>\n";
	$xml .= "		<record>\n";
	$xml .= "			<key>mental_state</key>\n";
	$xml .= "			<value>1</value>\n";
	$xml .= "			<captions>Happy|So-so|Sad|</captions>\n";
	$xml .= "			<choices>1|2|3|</choices>\n";
	$xml .= "		</record>\n";
	$xml .= "		<record>\n";
	$xml .= "			<key>vehicle</key>\n";
	$xml .= "			<value>ford</value>\n";
	$xml .= "			<captions></captions>\n";
	$xml .= "			<choices></choices>\n";
	$xml .= "		</record>\n";
	$xml .= "	</controls_select>\n";
	
	$xml .= "	<controls_id>\n";
	$xml .= "		<record>\n";
	$xml .= "			<key>h3_title</key>\n";
	$xml .= "			<value>Example Page</value>\n";
	$xml .= "		</record>\n";
	$xml .= "	</controls_id>\n";
	
	$xml .= "</root>\n";
	
	echo $xml;
	exit;
}
if ($request == 'submit') {
	$html = "";
	
	$html .= "First Name: " . $_POST["first_name"] . "<br />\n";
	$html .= "Last Name: " . $_POST["last_name"] . "<br />\n";
	$html .= "Date of Birth: " . $_POST["date_of_birth"] . "<br />\n";
	$html .= "Mental State: " . $_POST["mental_state"] . "<br />\n";
	$html .= "Hobby R/C Cars: " . $_POST["hobby_cars"] . "<br />\n";
	$html .= "Hobby Videogames: " . $_POST["hobby_games"] . "<br />\n";
	$html .= "Hobby Frisbee: " . $_POST["hobby_frisbee"] . "<br />\n";
	$html .= "Sex: " . $_POST["sex"] . "<br />\n";
	
	echo $html;
	exit;
}

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Example Merge Form With XML</title>

<script type="text/javascript" src="../common/jax-xmlhttprequest.js"></script>
<script type="text/javascript" src="jax-form.js"></script>

</head>

<body onLoad="jaxFormRegister('example.php?request=xml');">

<h3 id="h3_title">Example Jax Form</h3>

<form action="example.php?request=submit" method="POST">
<table>
	<tr><td>First Name:</td><td><input type="text" name="first_name" value="" /></td></tr>
	<tr><td>Last Name:</td><td><input type="text" name="last_name" value="" /></td></tr>
	<tr><td>Date of Birth</td><td><input type="text" name="date_of_birth" value="" /></td></tr>
	<tr>
		<td>Mental State:</td>
		<td>
			<select name="mental_state"></select>
		</td>
	</tr>
	<tr>
		<td>Vehicle:</td>
		<td>
			<select name="vehicle">
				<option value="dodge">Dodge</option>
				<option value="ford">Ford</option>
				<option value="gm">GM</option>
			</select>
		</td>
	</tr>
	<tr>
		<td>Sex:</td>
		<td>
			<input type="radio" name="sex" value="M">Male<br />
			<input type="radio" name="sex" value="F">Female<br />
		</td>
	</tr>
	<tr>
		<td>Hobbies:</td>
		<td>
			<input type="checkbox" name="hobby_cars">R/C Cars<br />
			<input type="checkbox" name="hobby_games">Videogames<br />
			<input type="checkbox" name="hobby_frisbee">Frisbee<br />
		</td>
	</tr>
	<tr><td></td><td><input type="submit" name="submit" value="Submit" /></td></tr>
</table>
</form>

</body>
</html>
Return current item: JaxBlog