PHP - ayuda con multiusuario

   
Vista:

ayuda con multiusuario

Publicado por aron (2 intervenciones) el 02/12/2015 21:24:45
acciones.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
<?php
 
require_once('../Models/user.php');
 
 
$boton=$_POST['boton'];
 
switch ($boton) {
	case 'cerrar':
			session_start();
			session_destroy();
		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_start();
				$_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;
}
?>


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
<?php
class user
{
	private $conexion;
	public function __construct()
	{
		require_once('conexion.php');
		$this->conexion= new conexion();
		$this->conexion->conectar();
	}
 
	function identification($username,$password){
		$pass=md5(sha1($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();
	}
}
?>


principal.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
  session_start();
  if (isset($_SESSION['login']) && $_SESSION['login']=='YES')
  {?>
    <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>punto</title>
 
    <link rel="stylesheet" href="../Resources/css/bootstrap.min.css">
    <link rel="stylesheet" href="../Resources/css/main.css">
 
</head>
 
<body>
<nav class="navbar navbar-default frm-nav">
        <div class="navbar-header">
            <a href="#" class="navbar-brand">Store</a>
        </div>
        <ul class="nav navbar-nav navbar-right">
            <li class="dropdrown">
             <a href="javascript:void(0)" onclick="" class="dropdown-toggle" data-toggle="dropdown"><span class="glyphicon glyphicon-user"></span> <?php echo $_SESSION['name'];?> <span class="caret"></span></a>
            <ul class="dropdown-menu" role="menu">
                <li><a href="javascript:void(0)" onclick="settings();"><span class="glyphicon glyphicon-cog"></span> Settings</a></li>
                <li><a href="javascript:void(0)" onclick="edit();"><span class="glyphicon glyphicon-edit"></span> Edit</a></li>
                <li><a href="javascript:void(0)" onclick="change();
                    "><span class="glyphicon glyphicon-repeat"></span> Change your password</a></li>
                <li class="divider"></li>
                <li><a href="javascript:void(0)" onclick="cerrar();"><span class="glyphicon glyphicon-off"> Sign out</span></a></li>
            </ul>
        </ul>
        <ul class="nav navbar-nav navbar-right">
        <li class="dropdown">
           <a href="javascript:void(0)" onclick="" class="dropdown-toggle" data-toggle="dropdown"><span class="glyphicon glyphicon-flag"></span> Reports<span class="caret"></span></a>
          <ul class="dropdown-menu" role="menu">
            <li><a href=""><span class="glyphicon glyphicon-list"></span> Items</a></li>
            <li><a href="#"><span class="glyphicon glyphicon-list"></span> I don't know yet</a></li>
          </ul>
        </li>
      </ul>
      <ul class="nav navbar-nav navbar-right">
        <li><a href="javascript:void(0)" onclick=""><span class="glyphicon glyphicon-home"></span> home</a></li>
        <li><a href="javascript:void(0)" id="low_stock" onclick=""><span class="glyphicon glyphicon-alert"></span> slow stock <span id="notif" class="badge">0</span></a></li>
      </ul>
</nav>   
<div class="col-md-3">
    <ul class="nav nav-pills nav-stacked">
        <li class="active"><a href="javascript:void(0)" onclick="home();"><span class="glyphicon glyphicon-home"></span> home</a></li>
        <li><a href="javascript:void(0)" onclick="product();"><span class=" glyphicon glyphicon-bed"></span> products</a></li>
        <li><a href="javascript:void(0)" onclick="sales();"><span class="glyphicon glyphicon-credit-card"></span> Sales</a></li>
       <li><a href="javascript:void(0)" id="msg" onclick="users();"><span class="glyphicon glyphicon-user"></span> Users <span id="notif" class="badge">0</span></a></li>
    </ul>
</div>
    <img src="../img/stone.jpg" class="img-responsive img-circle image">
    <script src="../Resources/js/jquery-1.11.2.js"></script>
    <script src="../Resources/js/bootstrap.min.js"></script>
    <script src="../Resources/js/actions.js"></script>
    <script>
        function cerrar()
        {
            $.ajax({
                url:'../Controllers/actions.php',
                type:'POST',
                data:"boton=cerrar"
            }).done(function(resp){
                location.href = '../Views/'
            });
        }
        
        $(function(){
            var message = $('#notif');
            $('#msg').append(message);
            message.show('slow');
        });
 
         $(function(){
            var message = $('#notif');
            $('#low_stock').append(message);
            message.show('slow');
        });
    </script>
</body>
</html>
 
<?php
 
  }
  else
  {
    header("location: ./");
  }
 ?>


quien me puede ayudar a implementar un multiusuario lo que tengo ya hecho he estado investigado pero no doy como
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder