<html>
<head>
</head>
<body>
This page takes a list of objects, one object per page, and displays them in a list using css.
<br /> <br />
Please fill in the box below:
<br /> <br />
<?php
//The POST variable is an array with each form item as an item in the index
//if the object list variable is not filled out then we ask the user to fill it in
/* Clicking the submit button does the form action: the same page again with the POST data the ' quotations will ignore the " quotations which is useful when outputing HTML but sometimes very hard to read (or debug, along with spaces between HTML options) the " quotations allow the \n newline to be output to the HTML code spacing
*/
print '<form action="' . $_SERVER['PHP_SELF'] . '" method="post">';
print "\n"; //making extra spacing obvious improves readability and debugging
print '<textarea name="objectlist" cols="40" rows="20">';
if( !isset($_POST['objectlist']) || empty($_POST['objectlist'] ) )
{
print "\n </textarea><br />";
print "\n";
print '<input type="submit" /></form>';
print "<br />";
/* The else allows the user to see what they typed in last time BUT for security no slashes! */
}
else{
print stripslashes($_POST['objectlist']);
print "</textarea><br />";
print '<input type="submit" /></form>';
print "<br />";
$object_list = $_POST['objectlist']; //one string for all of the user entered items
$object_lines = explode("\n", $object_list); //break the string into lines
print_r($object_lines); //dump the array for debugging
print "<br /> <br />";
/* the for loop takes each item in the array and copies it into the $value variable and it assigns the index to the $key variable. rtrim() removes the newline the user entered in the form.
*/
foreach( $object_lines as $key=>$value)
{
print '<div style="position: absolute; left: ' . (40+$key) . '%; top: ' . ($key+2) . 'em;">'; print $value;
print "</div>\n";
}
} //end of if-else user filled in textarea
?>
</body>
</html>