public function login_in2($datos = FALSE) { $objdata = new Database(); $sth = $objdata->prepare('SELECT * FROM users U inner join profiles P ' . 'ON U.idProf = P.idProfile ' . 'WHERE U.idUser = :id'); $sth->execute(array(':id' => $datos)); $data = $sth->fetch(); $count = $sth->rowCount(); if ($count > 0) { require 'sessions.php'; $objSess = new Sessions(); $objSess->init(); $objSess->set('login', $data['logUser']); $objSess->set('idpro', $data['idProf']); $objSess->set('profi', $data['profName']); switch ($data['profName']) { case 'Admin': header('location: ' . URL . 'admin/'); break; case 'Standard': header('location: ' . URL . 'dashboard/'); break; } } }
public function add() { $name = $_POST["name"]; $lastname = $_POST["lastname"]; $email = $_POST["email"]; $pass = $_POST["pass"]; $conf = $_POST["conf"]; if ($name == null or $lastname == null or $email == null or $pass == null or $conf == null) { header("location: Unirse.php?error=1"); } else { if ($pass != $conf) { header("location: Unirse.php?error=2"); } else { $sql = "select * from usuario where Email='" . $email . "'"; $result = $this->cone->procedure($sql); if ($result) { if (!$result->fetch_assoc()) { $sql = "select (count(idUsuario)+1) as 'newId' from usuario"; $result = $this->cone->procedure($sql); if ($result) { if ($row = $result->fetch_assoc()) { $sql = "insert into Usuario values (" . $row['newId'] . ",'" . $name . "','" . $lastname . "','" . $email . "','" . $pass . "',null)"; $rs = $this->cone->procedure($sql); if ($rs) { $ses = new Sessions(); $ses->init(); $ses->set("user", $email); header("location: ../User/index.php"); } else { header("location: Unirse.php?error=3"); } } } } else { header("location: Unirse.php?error=4"); } } } } }