Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $pole = array(1,2,3,4,5,6,7,8,9,0);
- $form = "<form method='POST' action='shuffle.php'>\n";
- if(isset($_POST["shuffle"]))
- {
- $form = $form."<input type='hidden' name='shuffled' value='shuffled' />\n";
- }else if(!isset($_POST["list"])){
- $form = $form."<input type='text' name='userInput' value='' />\n";
- $form = $form."<input type='submit' name='shuffle' value='Start!' />\n";
- }
- if(!isset($_POST["showed"])||isset($_POST["new"]))
- {
- shuffle($pole);
- echo "<table border='1'>\n";
- for($i=0; $i<count($pole); $i++)
- {
- echo "<tr><td>".($i+1)."</td><td>".$pole[$i]."</td></tr>\n";
- }
- echo "</table>\n";
- $numz = "";
- for($i=0; $i<count($pole); $i++)
- {
- $numz = $numz.$pole[$i].",";
- }
- $form = $form."<input type='hidden' name='list' value='$numz' />\n";
- $form = $form."<input type='hidden' name='showed' value='showed' />\n";
- }else{
- $oldInputs = array();
- if(isset($_POST["userInput"])&&!isset($_POST["userInputs"]))
- $oldInputs[0] = $_POST["userInput"];
- else if(isset($_POST["userInputs"]))
- $oldInputs = explode(",", $_POST["userInputs"]);
- else
- echo "Error!<br />";
- echo "oldInputs<br />\n";
- print_r($oldInputs);
- $form = $form."<input type='hidden' name='showed' value='showed' />\n";
- }
- if(isset($_POST["list"]))
- {
- $listValue = $_POST["list"];
- $form = $form."<input type='hidden' name='list' value='$listValue' />\n";
- $form = $form."<input type='text' name='userInput' value='' />\n";
- }
- if(isset($_POST["userInput"]))
- {
- $userInput = $_POST["userInput"];
- $oldInputs = "";
- if(isset($_POST["userInputs"]))
- $oldInputs = $_POST["userInputs"].$userInput.",";
- else
- $oldInputs = $userInput.",";
- $form = $form."<input type='hidden' name='userInputs' value='$oldInputs' />\n";
- }
- if(isset($_POST["shuffle"])||isset($_POST["list"]))
- $form = $form."<input type='submit' value='Odeslat' />\n";
- if(isset($_POST["counter"])){
- $counter = $_POST["counter"];
- $form = $form."<input type='hidden' name='counter' value='".($counter+1)."' />\n";
- }else
- $form = $form."<input type='hidden' name='counter' value='0' />\n";
- if(isset($_POST["counter"]))
- {
- echo "<table border='1'>";
- $counter = (int)$_POST["counter"];
- if(isset($_POST["list"]))
- $list = explode(",", $_POST["list"]);
- echo "counter = $counter<br />\n";
- if(isset($_POST["userInputs"]))
- $oldInputs = explode(",", $_POST["userInputs"]);
- for($i=0; $i<$counter; $i++)
- {
- if($list[$i]==$oldInputs[$i])
- echo "<tr><td>".($i+1)."</td><td bgcolor='green'>".$oldInputs[$i]."</td></tr>\n";
- else
- echo "<tr><td>".($i+1)."</td><td bgcolor='red'>".$oldInputs[$i]."</td></tr>\n";
- }
- }
- if(isset($_POST["counter"]))
- {
- $counter = (int)$_POST["counter"];
- /*if($counter == 10)
- {
- $pattern = "/<form.+
- preg_replace("<input type='submit' name='shuffle' value='Start!' />\n",
- }*/
- }
- //$form = $form."<input type='submit' />\n";
- $form = $form."</form>\n";
- echo $form;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement