-
Notifications
You must be signed in to change notification settings - Fork 0
/
valida_usuario.php
57 lines (41 loc) · 1.53 KB
/
valida_usuario.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
error_reporting(E_ALL);
session_start();
include('dao/db_con.php');
$sql = "SELECT cd_usuario, sn_usuario_preferencial
FROM usuario
WHERE ds_login = '".$_POST['ds_login']."'
AND ds_senha = '".$_POST['ds_senha']."' AND cd_empresa = '".$_POST['empresa']."' ";
//$result = mysql_query($sql);
//echo "aqui ".$_SESSION['db_con'];
//echo "aqiuo 2";
//print_r($_SESSION);
$stmt = $_SESSION['db_con']->prepare('SELECT cd_usuario, sn_usuario_preferencial FROM usuario WHERE ds_login = ? AND ds_senha = ? AND cd_empresa = ?');
$stmt->bind_param('ssi', $_POST['ds_login'], $_POST['ds_senha'], $_POST['empresa']);
$stmt->execute();
$result = $stmt->get_result();
$row = mysqli_fetch_array($result);
//$row = mysql_fetch_array($result);
if ($row['cd_usuario'] > 0)
{
$_SESSION['s_sn_usuario_preferencial'] = $row['sn_usuario_preferencial'];
$_SESSION['s_cd_usuario'] = $row['cd_usuario']; $_SESSION['s_cd_empresa'] = $_POST['empresa'];
if ($row['sn_usuario_preferencial'] == 'N')
{
if (date('D') == 'Sat' && ( (date('H') > 13 && date('i') > 30) || (date('H') < 8) ) ){
header("Location:index.php?fora_periodo=1");
} else if (date('D') == 'Sun') {
//echo 'aqui!!!!!';
header("Location:index.php?fora_periodo=1");
} else if (date('D') != 'Sat' && date('D') != 'Sun' && ((date('H') > 19 && date('i') > 30) || date('H') < 8) ) {
header("Location:index.php?fora_periodo=1");
} else {
header("Location:main.php");
}
} else {
header("Location:main.php");
}
}
else
header("Location:index.php?senha_errada=1");
?>