public function login() { $post = $this->app->request->post(); $response = array('codigo' => 0, 'mensaje' => '', 'datos' => array()); if (isset($post['txt_username']) && isset($post['txt_passwd'])) { $username = $post['txt_username']; $password = $post['txt_passwd']; $user = Usuarios::with('maestro', 'roles')->where('correo', $username)->where('password', $password)->get(); if (count($user) > 0) { $response['datos'] = $user; $response['codigo'] = 1; $response['mensaje'] = 'Credenciales correctas'; } else { $response['codigo'] = 0; $response['mensaje'] = 'Credenciales incorrectas'; } } else { $response['codigo'] = 0; $response['mensaje'] = 'Todos los parámetros son requeridos'; } echo json_encode($response); }
<?php require 'vendor/autoload.php'; $response = array('codigo' => '', 'mensaje' => ''); $db = Connection::getConnection(); $post = $_POST; $usuario = Usuarios::with('roles')->where('id', '=', $post['id_maestro'])->get(); if (count($usuario) > 0) { $db::beginTransaction(); try { $maestro = null; $maestro = Maestros::find($usuario[0]->id); if ($maestro == null) { $maestro = new Maestros(); $maestro->id_maestro = $usuario[0]->id; } $maestro->antiguedad_docen = $post['antiguedad_docen']; $maestro->antiguedad_laboral = $post['antiguedad_laboral']; $maestro->plaza_actual_id = $post['plaza_actual_id']; $maestro->deptos_academicos_id = $post['deptos_academicos_id']; $maestro->rfc = $post['rfc']; $maestro->estados_id = $post['estados_id']; $maestro->fecha_ingreso_sist = $post['fecha_ingreso_sist']; $maestro->escolaridad_id = $post['escolaridad_id']; $maestro->nombre_profesion = $post['nombre_profesion']; $maestro->plaza_aparticipar_id = $post['plaza_aparticipar_id']; $maestro->plaza_cat_id = $post['plaza_cat_id']; $maestro->save(); $db::commit(); $response['code'] = 1; $response['mensaje'] = "Se guardó correctamente";
<?php require 'vendor/autoload.php'; Connection::conecting(); $post = $_POST; $response = array('codigo' => 0, 'mensaje' => '', 'datos' => array()); if (isset($post['txt_username']) && isset($post['txt_passwd'])) { $username = $post['txt_username']; $password = $post['txt_passwd']; $user = Usuarios::with('maestro', 'roles')->where('correo', $username)->where('password', $password)->get(); if (count($user) > 0) { $response['datos'] = $user; $response['codigo'] = 1; $response['mensaje'] = 'Credenciales correctas'; } else { $response['codigo'] = 0; $response['mensaje'] = 'Credenciales incorrectas'; } } else { $response['codigo'] = 0; $response['mensaje'] = 'Todos los parámetros son requeridos'; } echo json_encode($response);
public function loginAction() { session_start(); $post = $this->app->request->post(); $action = $this->app->urlFor('login_view'); if (isset($post['txt_username']) && isset($post['txt_passwd'])) { $values = array('username' => $post['txt_username']); $username = $post['txt_username']; $password = $post['txt_passwd']; $user = Usuarios::with('roles')->where('correo', $username)->where('password', $password)->get(); if (count($user) > 0) { $session_user = array('email' => $username, 'rol' => $user[0]->roles[0]->rol); $_SESSION['user'] = $session_user; $action = $this->app->urlFor('index'); } else { $_SESSION['values'] = $values; $this->app->flash('error', 'Credenciales incorrectas'); } } $this->app->redirect($action); }