rendered paste body<html>
<head>
</head>
<body>
<?php
$list = array();
if(@$_POST['command']) {
$lowerLimit = @$_POST['lower'];
$upperLimit = @$_POST['upper'];
$direction = @$_POST['direction'];
$mult = @$_POST['mult'];
}
$error_msg=array();
if(!ctype_digit($lowerLimit)) $error_msg[] = "Lower Limit is not specified, or is not all digits.";
if(!ctype_digit($upperLimit)) $error_msg[] = "Upper Limit is not specified, or is not all digits.";
if(ctype_digit($upperLimit) && ctype_digit($lowerLimit)) {
if($lowerLimit > $upperLimit) $error_msg[] = "Lower Limit must be less than or equal to Upper Limit.";
}
if($error_msg > 0) {
echo "<h3>Your form has the following error(s)</h3>";
echo "<ul>\n";
foreach($error_msg as $err) {
echo "<li>".$err."</li>\n";
}
echo "</ul>\n";
echo "<hr />";
}
function add($x,$y) {
while($x <= $y) {
$list[] = $x;
$x++;
}
return $list;
}
function ascending($list) {
$list = array_values($list);
sort($list);
return $list;
}
function descending($list) {
$list = array_values($list);
rsort($list);
return $list;
}
function random($list) {
$list = array_values($list);
shuffle($list);
return $list;
}
function multi($list) {
$list = array_values($list);
for ($i = 0; $i < count($list); ++$i) {
$list[$i] *= 10;
}
return $list;
}
if($mult == yes) {
if($direction == 0) $list = ascending(multi($list));
elseif($direction == 1) $list = descending(multi($list));
elseif($direction == 2) $list = random(multi($list));
}
else {
if($direction == 0) $list = ascending($list);
elseif($direction == 1) $list = descending($list);
elseif($direction == 2) $list = random($list);
}
echo implode(",",$list);
?>
<form action="/test/last.php" method="post">
Lower Limit: <input type="text" name="lower" value="" size="6" maxlength="40"/> <br />
Upper Limit: <input type="text" name="upper" value="" size="6" maxlength="40"/> <br />
<input type="radio" name="direction" value="0" checked="checked">Ascending Order</input><br />
<input type="radio" name="direction" value="1" >Descending Order</input><br />
<input type="radio" name="direction" value="2" >Random Order</input><br />
<br />
<input type="checkbox" name="mult" value="yes" >Multiply by 10.</input><br />
<br />
<input type="submit" name="command" value="go"/> <input type="reset" name="reset" value="reset form"/><br />
<hr />
</form>
</body>
</html>