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 = "";
- private $db = "login";
- 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, nombre, apellido, usuario, password from wisher where usuario = '".$this->user."' and password = '".$this->password."' ";
- $consulta = $this->conexion->query($query); //error linea 34
- if ($row = mysqli_fetch_array($consulta)) {
- # code...
- session_start();
- $_session['id'] = $row['id'];
- $_session['nom'] = $row['nombre'];
- $_session['ape'] = $row['apellido'];
- echo "Has iniciado sesion";
- echo $_session['id'];
- echo $_session['nom'];
- echo $_session['ape'];
- }else {
- echo "usuario o contraseña incorrectos";
- }
- }
- }
- $c = new conexion;
- $c->login(...);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement