Código PHP:
<?php
/**
* Clase para acceso a datos
* @package dbAccess
*/
class conexion{
//atributos
private $host;
private $user;
private $pass;
private $mysqli;
private $db;
private $array = array();
function __construct(){
require_once ("conf.php");
$this->host = HOST;
$this->user = USER;
$this->pass = PASS;
$this->db = DB_;
}
public function connect(){
$this->mysqli = new mysqli($this->host, $this->user, $this->pass, $this->db);
//verificar conexion
if(mysqli_connect_errno()== 0){
return TRUE;
}else{
return FALSE;
}
}
public function close(){
return $this->mysqli->close();
}
public function consulta_usuario($usuario,$paswd){
include(Usuario.php);
include(Formulario.php);
$salida = array("error"=> "Problemas al consultar datos");
$query = 'SELECT Form_ced, Form_nomb,Form_apell
From Formulario F,Usuario U
WHERE U.Usua_codigo ='+ $codigo+'
AND U.Usua_Passw ='+ $passwd'
AND F.Form_ced = U.Usua_cod_cedu';
$result = $this->mysqli->query($query);
if($result->num_rows() > 0){
$row = $result->fetch_object();
$array = array("cedula"=> $row->Form_ced,
"nombre"=>$row->Form_nomb,
"apellido "=>$row->Form_apell);
$this->mysqli->free_result($result);
return $array;
}
}
Código HTML:
<!DOCUMENT html> <html> <head> </head> <header> </header> <body> <form name ="form1" action ="" method="POST" > <label> Usuario</label> <input type="Text" name="usuario" value="" size="8" maxlength="50"> <label>Password</label> <input type="password" name="passw" size="8" maxlength="50"> <input type="Submit" name="boton1" value="ENTRAR" > </form> [PHP] <?php if(isset($_POST['boton1'])){ echo "Ha precionado el boton <BR>"; if(!isset($_POST["usuario"],$_POST["passw"])){ echo "<p> Uno de los campos tiene un error o no se ha digitado</p>"; }else{ require('conexion.php'); $conectar = new conexion(); // $conectar->connect(); if($conectar->connect()){ echo "<BR>conexion realizada"; $verifica = $conectar->consulta_usuario($_POST["usuario"],$_POST["passw"]); if(isset($verifica)){ // echo "<p>Verificando que si entro</p>"; //$objetos = (Formulario) $verifica; echo var_dump($verifica["cedula"]); echo var_dump($verifica["nombre"]); echo var_dump($verifica["apellido"]); }else{ echo "Usuario no registrado/ Error al ingresar el usuario o contraseña"; } }else{ echo "Conexion no extablecida "; } } } ?> [/PHP]