예제 #1
0
파일: Usuario.php 프로젝트: villapilla/PHP
 public function persist()
 {
     $conexion = BD::getConexion();
     if ($this->getId() !== null) {
         $query = "update usuario SET nombre = :user, pass = :pass, email = :email, id_pintor = :pintor WHERE id_user = :id_usuario";
         $update = $conexion->prepare($query);
         try {
             $checkProcess = $update->execute(array(":user" => $this->getnombre(), ":pass" => $this->getPass(), ":email" => $this->getEmail(), ":pintor" => $this->getPintor(), "id_usuario" => $this->getId()));
         } catch (Exception $ex) {
             $checkProcess = null;
         }
         if ($checkProcess) {
             $pintor = $this->getPintor();
             $this->setPintor(Pintor::getPintor($pintor));
         }
     } else {
         $insert = "Insert into usuario (nombre,pass,email,id_pintor) values (:user, :pass, :email, :pintor)";
         $insercion = $conexion->prepare($insert);
         try {
             $checkProcess = $insercion->execute(array(":user" => $this->getnombre(), ":pass" => $this->getPass(), ":email" => $this->getEmail(), ":pintor" => $this->getPintor()));
         } catch (Exception $ex) {
             $checkProcess = null;
         }
         if ($checkProcess) {
             $this->setId($conexion->lastInsertId());
             $pintor = $this->getPintor();
             $this->setPintor(Pintor::getPintor($pintor));
         }
     }
     return $checkProcess;
 }
예제 #2
0
 public static function getUsuario($user, $pass)
 {
     $conexion = BD::getConexion();
     $query = "SELECT * from usuarios where user=:user AND pass=:pass";
     $prepara = $conexion->prepare($query);
     $prepara->setFetchMode(PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE, "Usuario");
     $prepara->execute(array(":user" => $user, ":pass" => $pass));
     $usuario = $prepara->fetch();
     if ($usuario !== 0) {
         $usuario->setPintor(Pintor::creaPintor($usuario->getPintor()));
     }
     return $usuario;
 }
예제 #3
0
파일: Usuario.php 프로젝트: jortiz-el/PhP
 public static function validar_usuario($usuario, $clave)
 {
     /*Creamos la instancia del objeto. ya estamos conectados*/
     $bd = Db::getInstance();
     $sql = "SELECT * FROM login WHERE usuario= :usuario AND clave= :clave";
     $stmt = $bd->prepare($sql);
     $stmt->execute([":usuario" => $usuario, ":clave" => $clave]);
     $stmt->setFetchMode(PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE, 'Usuario');
     $obj = $stmt->fetch();
     if ($obj) {
         $pintor = $obj->getPintor();
         $obj->setPintor(Pintor::get_Pintor($pintor));
     }
     return $obj;
 }
예제 #4
0
         </head>
         <body>
             <form action="index.php" method="POST">
                 <label for="userReg">Usuario</label><br>
                 <input type="text" name="userReg">
                 <br>
                 <label for="mailReg">E-mail</label><br>
                 <input type="email" name="mailReg">
                 <br>
                 <label for="passReg">Contraseña</label><br>
                 <input type="password" name="passReg">
                 <br>
                 <label for="pintores">Elija su pintor favorito</label><br>
                 <select name="pintores">
                 <?php 
 $pintores = Pintor::getPintores();
 foreach ($pintores as $num => $pintor) {
     echo "<option value=\"" . $pintor[0] . "\">" . $pintor[1] . "</option>";
 }
 ?>
                 <!-- Lo fácil
                     <option value="1">Boticceli</option>
                     <option value="2">Durero</option>
                     <option value="3">Da Vinci</option>
                     <option value="4">Miguel Angel</option>
                     <option value="5">Van Eyck</option>
                 -->
                 </select>
                 <input type="SUBMIT" value="Registrarse" name="botonRegistrarse">
             </form>
         </body>