EnSiSong

Untitled

Dec 17th, 2015
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. <HTML>
  2. <HEAD><TITLE>PHP form processor</TITLE></HEAD>
  3. <BODY BGCOLOR = 'white'>
  4.  
  5.  
  6. <?php
  7.  
  8. //Create start game condition
  9. if(){
  10. $pin = array("A" => array(0,1,2), "B" => array(),"C" => array());
  11. }else{
  12. //if the game has already started
  13. //perform a few checks
  14. //is the row that you are getting from empty? is the disk smaller that you are moving smaller than the one in the "to" column
  15. if( (count($pin[$_GET["from"]) => 0) || ($pin[$_GET["from"]][0] < $pin[$_GET["to"]][0])){
  16.  
  17.  
  18. // remove disk from the to array
  19. array_shift($_GET["from"]);
  20. // add disk to array
  21. array_unshift($_GET["to"]);
  22. }
  23. }
  24. ?>
  25.  
  26. <!-- shift unshift to add or remove circles form array -->
  27.  
  28. <!-- A=0,1,2&B= &C= -->
  29. <img src= "draw.php?A="<?php echo implode(",", $pin["A"]); ?>
  30. "&B="<?php echo implode(",", $pin["B"]); ?>
  31. "&C="<?php echo implode(",", $pin["C"]); ?>
  32. ">
  33. <form action = "play.php" method = "GET">
  34.  
  35. Move a disk from pin <input type = "text" name ="from">
  36. to pin <input type = "text" name = "to">
  37. <input type = "submit" value = "Move">.
  38.  
  39. </form>
  40.  
  41. </BODY>
  42. </HTML>
Advertisement
Add Comment
Please, Sign In to add comment