Return to Snippet

Revision: 10746
at January 12, 2009 10:16 by 1man


Initial Code
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
	<head>
		<title>PHP Test</title>
	</head>
	<body>
		<?php
		 	if(!isset($_POST['submit'])){
		?>
		
		<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
		Enter your age: <input name="age" size="2">
		<input type="submit" name="submit" value="Go">
		
		<?php 
			} else {
				//Grab the text we input
				$input = $_POST['age'];
				
				if($input < 27){
					echo "You are young";
				} elseif($input == 27){
					echo "The perfect age";
				} elseif($input > 27){
					echo "You are old!";
				}
			}
		?>
	</body>
</html>

Initial URL
http://devzone.zend.com/node/view/id/628

Initial Description
Simple PHP tutorial on how to use isset.

Initial Title
Use of PHP isset for a submit form

Initial Tags
form, php, html

Initial Language
PHP