Advertisement
Guest User

Untitled

a guest
Jul 16th, 2013
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. //Categories - EDIT VOOR NIEUWE SKILL!
  3. $categories = array (
  4.     0 => "Arrows",
  5.     1 => "Bows",
  6.     2 => "Bolts",
  7.     3 => "Crossbows",
  8.     4 => "Darts",
  9.     5 => "Dungeoneering",
  10.     6 => "Other",
  11. );
  12. ?>
  13.  
  14. <html>
  15. <head><title>Method XML-converter</title></head>
  16. <body>
  17. <?php
  18. //verwerk data en display
  19. if (isset($_POST["id"])) {
  20.   echo "<textarea cols=100 rows=12>";
  21.   //magic happens here
  22.   echo "        <method>\n";
  23.   echo "            <id>" . $_POST['id'] . "</id>\n";
  24.   echo "            <name>" . $_POST['name'] . "</name>\n";
  25.   echo "            <xp>" . $_POST['xp'] . "</xp>\n";
  26.   echo "            <level>" . $_POST['level'] . "</level>\n";
  27.   echo "            <categories>\n";
  28.   foreach ($_POST['check_list'] as $check) {
  29.     echo "              <category>" . $check . "</category>\n";
  30.   }
  31.   echo "            </categories>\n";
  32.   echo "        </method>\n";
  33.   echo "</textarea>";
  34.   //var_dump($_POST);
  35.   //Uncomment above line for debugging
  36. }
  37. ?>
  38. <form method="POST" action="convert.php">
  39. <table>
  40. <?php
  41. echo "<tr><td>ID</td><td><input type=\"text\" name=\"id\"";
  42. if (isset($_POST['id'])) {
  43.   $id = $_POST['id'] + 1;
  44.   echo " value=" . $id;
  45. }
  46. echo "></td></tr>";
  47. ?>
  48. <tr><td>Name</td><td><input type="text" name="name"></td></tr>
  49. <tr><td>XP</td><td><input type="text" name="xp"></td></tr>
  50. <tr><td>Level</td><td><input type="text" name="level"></td></tr>
  51. </table>
  52. <?php
  53. foreach($categories as $num => $val) {
  54.   echo '<input type="checkbox" name="check_list[]" value="' . $num . '"';
  55.   foreach ($_POST['check_list'] as $check) {
  56.     if ($num == $check) { echo " checked"; }
  57.   }
  58.   echo '>' . $val . '<br>';
  59. }
  60. ?>
  61. <input type="submit" value="Submit">
  62. </form>
  63. </body>
  64. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement