archivo user
Código
<?php require_once('../Models/user.php'); $boton=$_POST['boton']; switch ($boton) { case 'cerrar': break; case 'login': $username = $_POST['username']; $password = $_POST['password']; $ins = new user(); $array=$ins->identification($username,$password); if ($array[0]==0) { echo '0'; } else { $_SESSION['login']='YES'; $_SESSION['name']=$array[1]; } break; case 'show_product': $instancia = new product(); echo $instancia->show_product(); break; case 'delete_product': $code = $_POST['code']; $delete = new product(); if($delete->del($code)){ echo "success"; } else{ echo "there is something wrong"; } break; } ?>
usario_model.php
Código
<?php class user { private $conexion; public function __construct() { require_once('conexion.php'); $this->conexion= new conexion(); $this->conexion->conectar(); } function identification($username,$password){ $sql="SELECT * FROM users WHERE username ='$username' && password ='$pass'"; $record = $this->conexion->conexion->query($sql); if ($record->num_rows > 0) { $row=$record->fetch_array(); } else{ $row[0]=0; } return $row; $this->conexion->cerrar(); } } ?>