tengo lo siguiente que ya he corregido, la idea es que logee y vaya mostrando ciertas cosas para ciertos niveles; pero no realiza creo ninguna consulta adjunto el code
config1.php
Código PHP:
Ver original<?
// Configura los datos de tu cuenta
$dbhost="localhost";
$dbusername="root";
$dbuserpass="123456";
$dbname="yino";
// Conexión a la base de datos
// Seleccion de la base de datos
?>
Luego el archivo index.php
Código PHP:
Ver original<?
require_once('config1.php');
//cargar variables
if($_POST['submit']) {
$user = $_POST["username"];
$pass = $_POST["password"];
}
//carga SESSION
if ($_SESSION['username']) {
$user = $_SESSION['username'];
$nivel = $_SESSION['nivel'];
}
//funcion de identificacion
if($_POST['submit']) {
echo "se envia submit";
$check_user = mysql_query('SELECT * FROM usuarios WHERE username= " $user " and password= " $pass " '); echo $username_exist;
if ($username_exist > 0) { // identificacion de usuarios existosa
echo "$username_exist > o TRUE";
$sql_nivel = 'SELECT * FROM usuarios WHERE username=" $user "';
//$num = mysql_numrows ($checknivel);
//$row = mysql_fetch_row($checknivel);
//$row = mysql_fetch_assoc($checknivel);
//while $row = mysql_fetch_assoc($checknivel) {
$nivel = $row['nivel'];
$_SESSION['username'] = $user;
$_SESSION['nivel'] = $nivel;
}
echo "<font color=\"#FF0000\"><b>Thank you for login in, you will be redirected to the protected pages in 2 seconds <META HTTP-EQUIV=\"refresh\" CONTENT=\"2; URL=index.php\"></b></font>";
}
}
if ($_GET['func'] == "logout") {
// vaciarla
} elseif ($_GET['func'] == "err1") {
echo "error de logeo";
} else {
echo "";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<title><? echo $website; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="generator" content="handmade" />
<style type="text/css">
<!--
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
background-color: #DDDDDD;
}
.cnt {
text-align: center;
}
.cnt_welcome {
font-size: 16px;
font-weight: bold;
text-align: center;
}
.cnt_powered {
font-size: 14px;
font-weight: bold;
text-align: center;
}
.cnt_small {
font-size: 12px;
text-align: center;
padding-top: 50px;
}
.head_line {
background-color: #BBBBBB;
}
.main_table {
border: solid 1px #9D9992;
font-size: 13px;
}
h4 {
font-size: 12px;
color: #DD0000;
text-align: center;
}
.button {
border: 1px solid #55555;
font-weight: bold;
}
-->
</style>
</head>
<body>
<table width="790" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2"><img src="images/logo_elearning.jpg" alt="" width="300" height="82" /></td>
</tr>
<tr>
<td width="250">
Bienvenido <? echo $user; ?> <br />
Nivel : <? echo $nivel; ?> <br />
<blockquote>
- Inicio<br />
- Mis cursos<br />
- Inscripcion<br />
- <a href="?func=logout">Salir</a><br />
</blockquote>
<br />
</td>
<td width="540">
<?
//if (!$_SESSION['username']) {
if ($_GET['func'] == "login") {
?>
<center>
<h2>Bienvenido al sistema de educacion e-learning para el aprendizaje de corriente alterna</h2>
<form name="form1" method="post" action="index.php">
Username:<br><input name="username" type="text" id="username"><br>
Password:<br><input name="password" type="password" id="password"><br><br>
<input name="submit" type="submit" id="submit" value="Login!"><br><br>
</form>
</center>
<?
} else {
echo "se muestra el bloque de cursso que lleva el alumno o profesor, segun varios aspectos";
}
//Se carga el contexto para el cpanel segun las funciones enviadas por metodo $_GET
if ($_GET['func'] == "logout") {
echo "Desconectando del sistema ...";
echo "<font color=\"#FF0000\"><b>Logout satisfactorio<META HTTP-EQUIV=\"refresh\" CONTENT=\"2; URL=index.php?func=login\"></b></font>";
} elseif ($_GET['func'] == "x") {
echo "x";
}
?>
</td>
</tr>
<tr>
<td colspan="2"><center><font face="courier" size="1.5">Desing by ....</font></center></td>
</tr>
</table>
</body>
</html>