浏览代码

Completando index.php

Okynos 9 年之前
父节点
当前提交
eee8ac35e9
共有 1 个文件被更改,包括 5 次插入3 次删除
  1. 5 3
      index.php

+ 5 - 3
index.php

@@ -2,7 +2,7 @@
 
 <body>
   <h1>Practica 1 Cloud Computing</h1>
-  <form action="/action_page.php">
+  <form action="index.php?insert=true">
     <fieldset>
       <legend>Formulario de datos</legend>
       Nombre:<br>
@@ -15,12 +15,14 @@
 
 <div>
   <h2>Elementos en la Base de datos</h2>
-  <div class="elements" style="border:thin">
+  <div class="elements" style="border:1px solid black;">
     <?php
       $c = new MongoClient( "mongodb://docker.ugr.es:15074" );
       $db = $c->test->elements;
       if(isset($_GET['remove']){
-        $db->remove({});
+        $db->remove( array('name' => $_GET['remove']) );
+      }else if(isset($_GET['insert'])){
+        $db->insert( array('name' => $_POST['name'], 'email' => $_POST['email']) );
       }
       $cursor = $db->find();
       foreach ($cursor as $documento) {