function checkStorySubmission() { //make sure posted storyName is valid $num = htmlentities($_POST['storyNum'], ENT_QUOTES); if ($num < 1 || $num > 3) { showStoryChoice(); return; } $filename = "story" . $num . ".txt"; $subfilename = "story" . $num . "sub.txt"; $contents = file_get_contents($filename); $contents2 = file_get_contents($subfilename); print "<div><h2>Original Story</h2>\n"; print $contents; print "<h2> Modified Sub Story</h2>\n"; print $contents2; print "<h2> Found Whole Matches </h2>\n"; $pattern = "/\\[(.*?)\\]/"; preg_match_all($pattern, $contents2, $matches); for ($i = 0; $i < count($matches[0]); $i++) { print $matches[0][$i] . "<br>"; } print "<h2> Subgroup of Matches </h2>"; for ($i = 0; $i < count($matches[0]); $i++) { print $matches[1][$i] . "<br>"; } print "<br><br>\n"; startOverLink(); print "</div>\n"; }
function storySubmissionForm($subs = array()) { //make sure posted storyName is valid $num = htmlentities($_POST['storyNum'], ENT_QUOTES); if ($num < 1 || $num > 3) { showStoryChoice(); return; } $self = $_SERVER['PHP_SELF']; $subfilename = "story" . $num . "sub.txt"; $contents = file_get_contents($subfilename); print "<form method='post' action='{$self}'>\n" . "<div>\n<h2>Fill out the Form</h2>\n"; $pattern = "/\\[(.*?)\\]/"; preg_match_all($pattern, $contents, $matches); for ($i = 0; $i < count($matches[0]); $i++) { print "Enter a " . $matches[1][$i] . ":" . "<input type='text'" . "\n" . "name='subs[]' value='" . $subs[$i] . "'/><br>\n"; $count++; } print "<input type='hidden' name='storyNum' value={$num}>"; print "<br /><input type='submit' name='submitInfo' value='Submit'/>"; print "<br /><br />\n"; startOverLink(); print "</div></form>\n"; }