
La variable $_SESSION['username'] nunca coge valor
Publicado por Victor (195 intervenciones) el 05/06/2013 23:07:01
Buenas Gente.
Necestio que alguien me explique el motivo por el cual las acciones que intento realizar en en el codigo php que contiene las funciones a realizar no repercute despues en el interfaz,tambien controlado por funciones.
En este caso,necesito que se oculte o no un ul con informacion del usuario.
Lo he esta comprobando y parece ser que el $_SESSION['username'] nunca coge valor.
Alguna sugerencia?
Me urge entender por que sucede eso.
Gracias.
este es el index.php
Este el fichero con las funciones de la interfaz grafica:
Y este es un fichero que realiza acciones que deberia repercutir en fuction frmLogin
Necestio que alguien me explique el motivo por el cual las acciones que intento realizar en en el codigo php que contiene las funciones a realizar no repercute despues en el interfaz,tambien controlado por funciones.
En este caso,necesito que se oculte o no un ul con informacion del usuario.
Lo he esta comprobando y parece ser que el $_SESSION['username'] nunca coge valor.
Alguna sugerencia?
Me urge entender por que sucede eso.
Gracias.
este es el index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
"<?php
/**
* Created by JetBrains PhpStorm.
* User: A
* Date: 19/05/13
* Time: 18:52
* To change this template use File | Settings | File Templates.
*/
include("portada.php");
portada();
?>"
Este el fichero con las funciones de la interfaz grafica:
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
"<?php
/**
* Created by JetBrains PhpStorm.
* User: A
* Date: 19/05/13
* Time: 18:56
* To change this template use File | Settings | File Templates.
*/
function portada()
{
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE7"/>
<style type="text/css">
* {
padding:0px;
margin:0px;
}
.tabla{
height: 100%;
}
.Menu {
font-family:arial,helvetica,sans-serif;
position: static;
min-width: 800px;
}
ul, ol {
list-style:none;
}
.nav li{
width: 120px;
}
.nav li a{
color:white;
background-color:black;
text-decoration:none;
padding:10px 15px;
display: block;
}
.nav li a:hover{
background-color:#434343;
}
.nav > li {
float:left;
}
.nav > ul{
width: 180px;
}
.nav li ul{
display:none;
position:absolute;
min-width:140px;
}
.nav li:hover > ul{
display:block;
}
.nav li ul li{
position:relative;
}
.nav li ul li ul li{
right:-140;
top:0px;
}
.tabla{
background-color: #7fffd4;
width: 100%;
}
.parteSuperior{
position: relative;
}
.pagina{
width: 1130px;
margin: 0 auto;
}
.liUsuario{
font-family: arial;
visibility: hidden;
}
</style>
</head>
<body>
<div class="pagina">
<div class="parteSuperior">
<table>
<tr>
<td>
<table cellspacing="0" cellpadding="0" >
<tr>
<td height="99" width="100%">
<a href="index.php"><img src="imagenes\cas1.jpg" style="height: 100%" width="1130px" /></a>
</td>
</tr>
<tr>
<td class="Menu" name='Menu' align="center" style="width: 800px;">
<ul class="nav" name="nav">
<li style="width: 119px;visibility: hidden;"><a href="#"></a>
<ul>
<br>
</ul>
</li>
<li><a href="#">Hombre</a>
<ul>
<li><a href="#">Pantalones</a></li>
<li><a href="#">Camisetas</a></li>
<li><a href="#">Sudaderas</a></li>
</ul>
</li>
<li><a href="#">Mujer</a>
<ul>
<li><a href="#">Pantalones1</a></li>
<li><a href="#">Camisetas1</a></li>
<li><a href="#">Sudaderas1</a></li>
</ul>
</li>
<li style="font-family: arial"><a href="#">Junior</a>
<ul>
<li><a href="#">Pantalones2</a></li>
<li><a href="#">Camisetas2</a></li>
<li><a href="#">Sudaderas2</a></li>
</ul>
</li>
<li style="font-family: arial"><a href="#">Deportes</a>
<ul>
<li><a href="#">Pantalones2</a></li>
<li><a href="#">Camisetas2</a></li>
<li><a href="#">Sudaderas2</a></li>
</ul>
</li>
<li><a href="#">Contacto</a></li>
<li><a href="#">Acerca de</a></li>
<li id="liLogin" name="liLogin" style="font-family: arial;"><a href="login.php">Acceso</a>
</li>
<li id="liUsuario" name="liUsuario" style="font-family: arial; display:none">
<ul>
</ul>
</li>
</ul>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<?php
}
function frmLogin()
{
?>
<table class="tabla" width="100%">
<tr>
<td>
<table style="margin: 0 auto;margin-top: 50px">
<tr>
<td>
<p style="text-align: justify"><b>Itroduzca su nombre de usuario y contraseña</b></p>
</td>
</tr>
<tr>
<td>
<form action="login.php" method="post" name="frmLogueo">
<table bgcolor="#adff2f" height="99">
<tr>
<td>Nombre Usuario</td>
<td>
<input type="text" name="username"/>
</td>
</tr>
<tr>
<td align="right">Password</td>
<td>
<input type="password" name="password"/>
</td>
</tr>
<tr>
<td align="right">
<input type="submit" value="login"/>
</td>
<td>
<a style="background: none;padding: 0; width:95px;color: black;text-decoration: underline" href="registroUsuarios.php">Crear Cuenta</a>
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</td>
</tr>
</table>
<?php
}
"
Y este es un fichero que realiza acciones que deberia repercutir en fuction frmLogin
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
"<?php
require('funciones_bd.php');
require('portada.php');
frmlogin();
session_start();
if(($_POST['username']) && ($_POST['password']))
{
//Una vez que comprobamos si nos han mandado datos.
$user = trim($_POST['username']);
$pass = trim($_POST['password']);
if(login($user,$pass))
{
$_SESSION['username']= $_POST['username'];
session_name($_SESSION['username']);
if($_SESSION['username'] !="")
{?>
<script type="text/javascript" charset="">
function quitamenu()
{
nomUsuario=document.getElementById('idUsuario');
nomUsuario.style.display = true;
mnuAcceso=document.getElementById('frmLogin').display="none";
}
</script>
<?php
} ?>
<?php
}else{
echo "no has iniciado sesion";
}
}"
Valora esta pregunta


0