Advertisement
Guest User

Untitled

a guest
Jul 19th, 2016
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.17 KB | None | 0 0
  1. <html>
  2. <head>
  3. <link href="PPC.css" rel="stylesheet" type="text/css">
  4. </head>
  5. <center>
  6. <body>
  7. <div class="container">
  8. <header>
  9. <div class="primary_header" id="title">
  10. <h1 class="title"><a href="PetalPetCareSAT.php">Petal Pet Care</a></h1>
  11. </div>
  12. <nav class="secondary_header" id="menu">
  13. <ul>
  14. <li id="selected">ANIMAL INPUT</li>
  15. <li><a href="Howto.php">HOW TO USE</a></li>
  16. <li><a href="Database.php">ANIMAL DATABASE</a></li>
  17. </ul>
  18. </nav>
  19. </header>
  20. </div>
  21. <?php
  22. /*----------------------------
  23. Function write_xml
  24. Writes data to xml
  25. -----------------------------*/
  26. function write_xml($anm_name,$own_name,$sign_in,$meds,$spec,$food,$note){
  27.  
  28. $file = 'data.xml';
  29.  
  30. $elem = new SimpleXMLElement("data.xml",null,true);
  31.  
  32. $count= count($elem->data);
  33.  
  34. $count +=1;
  35. //print_r($count);
  36.  
  37.  
  38. $date=date("d/m/Y");
  39. $xml = simplexml_load_file($file);
  40.  
  41. $load = $xml->measures;
  42.  
  43. $help = $xml->addChild('data');
  44. $help->addChild('anm_name', $anm_name);
  45. $help->addChild('own_name', $own_name);
  46. $help->addChild('sign_in', $sign_in);
  47. $help->addChild('meds', $meds);
  48. $help->addChild('spec', $spec);
  49. $help->addChild('food', $food);
  50. $help->addChild('note', $note);
  51. $help->addChild('ID', $count);
  52. $xml->asXML($file);
  53. //print_r($xml);
  54. }
  55. ?>
  56. <section>
  57. <article class="output_article">
  58. <!--- Check if submitted and ANM_NAME is set and not empty -->
  59. <?php
  60. if(!empty($_POST['submit'])){
  61. if (isset($_POST['ANM_NAME']) && ! empty($_POST['ANM_NAME'])) { ?>
  62. <!-- Results if displayed -->
  63. <h3> <br>
  64. Output </h3>
  65. <table>
  66. <tr>
  67. <th>Animal Name</th>
  68. <td><?php echo $_POST["ANM_NAME"];?></td>
  69. </tr>
  70. <tr>
  71. <th>Owner Name</th>
  72. <td><?php echo $_POST["OWN_NAME"]; ?></td>
  73. </tr>
  74. <tr>
  75. <th>Sign in Date</th>
  76. <td><?php echo $_POST["SIGN_IN"]; ?></td>
  77. </tr>
  78. <tr>
  79. <th>Medication</th>
  80. <td><?php echo $_POST["MEDS"]; ?></td>
  81. </tr>
  82. <tr>
  83. <th>Special Requirements</th>
  84. <td><?php echo $_POST["SPEC"]; ?></td>
  85. </tr>
  86. <tr>
  87. <th>Food</th>
  88. <td><?php echo $_POST["FOOD"]; ?></td>
  89. </tr>
  90. <tr>
  91. <th>Note</th>
  92. <td><?php echo $_POST["NOTE"]; ?></td>
  93. </tr>
  94. </table>
  95. <br>
  96. <form method="get" action="AnimalInput.php">
  97. <button type="submit" id="button">Input New Data</button>
  98. </form>
  99. <!-- Declaration of basic variables -->
  100. <?php
  101. $anm_name=$_POST["ANM_NAME"];
  102. $own_name=$_POST["OWN_NAME"];
  103. $sign_in=$_POST["SIGN_IN"];
  104. $meds=$_POST["MEDS"];
  105. $spec=$_POST["SPEC"];
  106. $food=$_POST["FOOD"];
  107. $note=$_POST["NOTE"];
  108. write_xml($anm_name,$own_name,$sign_in,$meds,$spec,$food,$note);
  109. }
  110. }else{
  111. ?>
  112. <!--Data input and sectioning -->
  113. <h3>
  114. <br>
  115. Data Input
  116. <form action= "<?php $_SERVER['PHP_SELF'];?>" method="post" name="input" id="input">
  117. <br>
  118. <table>
  119. <tr>
  120. <th>Animal Name</th>
  121. <td><input type="text" name="ANM_NAME" id="ANM_NAME"></td>
  122. </tr>
  123. <tr>
  124. <th>Owner Name</th>
  125. <td><input type="text" name="OWN_NAME" id="OWN_NAME"></td>
  126. </tr>
  127. <tr>
  128. <th>Sign in</th>
  129. <td><input type="date" name="SIGN_IN" id="SIGN_IN"></td>
  130. </tr>
  131. <tr>
  132. <th>Medication</th>
  133. <td><input type="text" name="MEDS" id="MEDS"></td>
  134. </tr>
  135. <tr>
  136. <th>Special Requirements</th>
  137. <td><input type="text" name="SPEC" id="SPEC"></td>
  138. </tr>
  139. <tr>
  140. <th>Food</th>
  141. <td><input type="text" name="FOOD" id="FOOD"></td>
  142. </tr>
  143. <tr>
  144. <th>Notes</th>
  145. <td><input type="text" name="NOTE" id="NOTE"></td>
  146. </tr>
  147. </table>
  148. <br>
  149. <input type="submit" id="button" value="Submit" disabled="disabled">
  150. </form>
  151. <?php } ?>
  152. </center>
  153. </h3>
  154. </article>
  155. </section>
  156. </body>
  157. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement