All pastes #403998 Raw Edit

Untitled

public text v1 · immutable
·published 2007-03-20 19:20 UTC
rendered paste body
<html>
<head> </head>
<body>
  <?php
	$size = "3";
	$step = "1";
	$submit = isset($_POST['command']);	

	
	echo '<form action="'.$_SERVER['PHP_SELF'].'" method="post">';

	function form1($size) {
		echo '<input type="hidden" name="step" value="1" />
  		Size: <input type="text" name="size" value="'.$size.'" size="6" maxlength="40"/>&nbsp';
	}

	function form2($size) {
		echo '<input type="hidden" name="step" value="'.$step.'" />
  		      <input type="hidden" name="size" value="'.$size.'" />';
	
		for($i=0; $i < $size; ++$i) {
			echo '<select name="v'.$i.'">';
			echo '<option value="0" selected="selected"> unset </option>';
			for($j=1; $j < 20; ++$j) {
				echo'<option value="'.$j.'">'.$j.'</option>';
			}
			echo '</select>';
		}
		echo '<br />';
	}

	if($submit) {
		$size = $_POST['size'];
		if($size == "" || !ctype_digit($size) || $size > 12 || $size < 1) {
				print "size must be an integer between 1 and 12 (inclusive)";
				print "<br />"; 		
			}
		else { $step += 1;
		}
	}
	

	switch($step) {
		case 2: 
			form2($size);
		break;
		default: 
			form1($size);
	}
	echo '<input type="submit" name="command" value="go"/><br />
	      </form>';	
	








  ?>
</body>
</html>