Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class conexion {
- private $conexion;
- private $server = "localhost";
- private $usuario = "root";
- private $pass = "aassdd";
- private $db = "Agropacdb;"
- private $user;
- private $password;
- public function_construct() {
- $this->conexion = new mysqli($this->server, $this->usuario, $this->pass, $this->db);
- if($this->conexion->connect_errno){
- die("Fallo al tratar de conectar con MySQL: (". $this->conexion->connect_errno.")");
- }
- }
- public function cerrar() {
- $this->conexion->close();
- }
- public function login($usuario, $pass) {
- $this->user = $usuario;
- $this->password = $pass;
- $query = "SELECT id_u, nombre_u, apellido_u, alt_u, pass_u From Usuarios WHERE alt_u = '".$this->user."' and pass_u = '".$this->password."' ";
- $consulta = $this->conexion->query($query);
- if($row = mysqli_fetch_array($consulta)){
- session_start();
- $_session['id'] = [$id_u];
- $_session['nom'] = [$nombre_u];
- $_session['ape'] = [$apellido_u];
- echo "Has iniciado sesion";
- echo $_session['id'];
- echo $_session['nom'];
- echo $_session['ape'];
- } else {
- echo "Usuario o contrasena incorrectos";
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement