index.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <!DOCTYPE html>
  2. <html>
  3. <body background="http://static6.depositphotos.com/1024166/554/v/950/depositphotos_5540906-stock-illustration-seamless-background.jpg">
  4. <div style="border:1px solid black;background:rgba(3,170,248,0.7); border-radius:15px; padding:1%">
  5. <h1>Practica 1 Cloud Computing</h1>
  6. <form action="index.php?insert=true" method="POST">
  7. <fieldset>
  8. <legend>Formulario de datos</legend>
  9. Nombre:<br>
  10. <input type="text" name="name" placeholder="Nombre"><br>
  11. E-mail:<br>
  12. <input type="text" name="email" placeholder="example@example.com"><br><br>
  13. <input type="submit" value="Enviar">
  14. </fieldset>
  15. </form>
  16. </div>
  17. <div style="border:1px solid black;background:rgba(3,170,248,0.7); border-radius:15px; padding:1%">
  18. <h2>Elementos en la Base de datos</h2>
  19. <div class="elements">
  20. <ul>
  21. <?php
  22. $c = new MongoClient( "mongodb://docker.ugr.es:15074" );
  23. $db = $c->test->elements;
  24. if( isset($_GET['remove']) ){
  25. $db->remove( array('name' => $_GET['remove']) );
  26. }else if( isset($_GET['insert']) ){
  27. $db->insert( array('name' => $_POST['name'], 'email' => $_POST['email']) );
  28. }
  29. $cursor = $db->find();
  30. foreach ($cursor as $documento) {
  31. echo "<li> Nombre: " . $documento["name"] . " -- E-mail: " . $documento["email"] . " ---> <a href='index.php?remove=".$documento["name"]."'>Eliminar usuario</a></li>";
  32. }
  33. ?>
  34. </ul>
  35. </div>
  36. </div>
  37. </body>
  38. </html>