Example #1
0
function sText_Protect($str, $con)
{
    $str = trim($str);
    $str = htmlentities($str);
    $str = preg_replace('/\\s(?=\\s)/', '', $str);
    $str = preg_replace('/[\\n\\r\\t]/', '', $str);
    $str = $con->real_escape_string($str);
    return $str;
}
if (isset($_POST['usuario']) && !empty($_POST['usuario'])) {
    $usuario = sText_Protect($_POST['usuario'], $cnn_mysqli);
} else {
    $avMensaje[] = 'Escribe el nombre del usuario';
}
if (isset($_POST['password']) && !empty($_POST['password'])) {
    $password = sText_Protect($_POST['password'], $cnn_mysqli);
} else {
    $avMensaje[] = 'Escribe la contraseña';
}
$countError = count($avMensaje);
$msg = "";
//-------------
if ($countError > 0) {
    for ($i = 0; $i < $countError; $i++) {
        echo ucfirst($avMensaje[$i]) . '<br/>';
    }
} else {
    //----escribio usu y pwd--
    $sSql = " SELECT idusu FROM catusuarios WHERE lgnusu = '{$usuario}' and estatus=1 ";
    $rs = $cnn_mysqli->query($sSql);
    $row = $rs->fetch_row();
Example #2
0
function sText_Protect($str, $con)
{
    $str = trim($str);
    $str = htmlentities($str);
    $str = preg_replace('/\\s(?=\\s)/', '', $str);
    $str = preg_replace('/[\\n\\r\\t]/', '', $str);
    $str = $con->real_escape_string($str);
    return $str;
}
if (isset($_POST['usuario']) && !empty($_POST['usuario'])) {
    $usu = sText_Protect($_POST['usuario'], $cnx);
} else {
    $avMensaje[] = 'Escribe el nombre del usuario';
}
if (isset($_POST['password']) && !empty($_POST['password'])) {
    $pwd = sText_Protect($_POST['password'], $cnx);
} else {
    $avMensaje[] = 'Escribe la contrase&ntilde;a';
}
$countError = count($avMensaje);
$msg = "";
//-------------
if ($countError > 0) {
    for ($i = 0; $i < $countError; $i++) {
        echo ucfirst($avMensaje[$i]) . '<br/>';
    }
} else {
    //----escribio usu y pwd--
    $sSql = " SELECT idusu FROM catusuarios WHERE lgnusu = '" . $usu . "' and pwdusu=md5('" . $pwd . "')";
    $rs = $cnx->query($sSql);
    $row = $rs->fetch_row();