Miren tengo un problema y es el siguiente., Intento oculta un formulario de login cuando el usuario se ha logueado y mostrarle en mensaje de bienvenida. y le e hecho así pero no funciona.
Código PHP :
<?php require_once('conexion.php'); ?>
<?php
mysql_select_db($database_mhh, $mhh);
// username and password sent from form
$myusername=$_POST['usuario'];
$mypassword=$_POST['pass'];
// To protect MySQL injection (more detail about MySQL injection)
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$sql="SELECT * FROM mitabla WHERE apodo='$myusername' and pass='$mypassword'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("myusername");
session_register("mypassword");
$_SESSION['is_log']=true;
header("location:zona.php");
}
else {
header("location:login_error.php");
}
?>
<html>
<body>
<?php
session_start();
if($_SESSION['is_log']){
echo '<table width="95%" border="0" cellpadding="0" cellspacing="0" align="center">
<tr>
<td width="8%" align="center">'.date("d-m-Y").'</td>
<td width="4%" align="right"> </td>
<td width="79%" align="right">Holaxxx, '.$_SESSION['MM_Username'] .' . Gracias por volver de nuevo</td>
<td width="9%" align="center"><a href="logout.php" class="a_cabecera">Desconectar</a></td>
</tr>
</table>';
}else{
echo '<form id="login" name="login" method="post" action="login.php">
<table width="95%" border="0" cellpadding="0" cellspacing="0" align="center">
<tr>
<td width="8%" align="center">'.date("d-m-Y").'</td>
<td width="2%" align="right"> </td>
<td width="53%" align="right">Bienvenido . Inicia tú sesión o <a href="../alta.php" class="a_cabecera">registrate</a></td>
<td width="7%" align="right"><strong>Usuario:</strong></td>
<td width="11%" align="right"><input name="usuario" type="text" class="input_login" id="usuario" onkeypress="return validarn(event)" /></td>
<td width="8%" align="right"><strong>Contraseña:</strong></td>
<td width="11%" align="right"><label for="pass"></label>
<input name="pass" type="password" class="input_login" id="pass" onkeypress="return validarn(event)" /></td>
<td width="6%" align="right"><input name="send" type="submit" class="bt_login" id="send" value="Entrar" /></td>
</tr>
</table>
</form>';
}
?>
</body>
</html>
Podrian ayudarme por favor. Muchas gracias de antemano!
