<?php
Header("Cache-Control: no-store, no-cache, must-revalidate");
session_start();
include_once("ctr/beginsesion.php");
if ($_SESSION['expired']=='yes')
echo "<script languaje='javascript'>location.href = 'ctr/expired.html'</script>";
else{
if (!isset($_SESSION['userRegistro'])){
echo "<script languaje='javascript'>location.href = 'index.php'</script>";
} else
{
if ($_SESSION['typeuser']==1){
echo "<script languaje='javascript'>location.href = 'listaadmin.php'</script>";
}else
{
echo "<script languaje='javascript'>location.href = 'listauser.php'</script>";
}
}
}
?>
BBDD
create table usuario(
nomusu varchar(50),
clausu varchar(255),
constraint pk_usuario primary key(nomusu));
INDEX
<!doctype html>
<html lang="es" id="cs">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript">
</script>
</head>
<body >
<center><div>
<form method="POST" action="ctr/create.php">
<table width="490px" height="600px">
<tr>
<td >
<div style="background:url(img/login.png);height:410px;vertical-align: middle;text-align: center;">
<center>
<div style="position: absolute;left: 50%;top: 50%;width: 300px;height: 200px;margin-top: -100px;margin-left: -150px;">
<table style="vertical-align:middle;">
<tr>
<td><font size="2" color="#000"><b>USUARIO:</b></font>
</td>
<td>
<input id="txtUsuario" name="txtUsuario" type="text" style ="width:200px">
</td>
</tr>
<tr>
<td><font size="2" color="#000"><b>CLAVE:</b></font>
</td>
<td>
<input id="txtClave" name="txtClave" type="password" style ="width:200px">
</td>
</tr>
<tr>
<td colspan="2" style="text-align: right;">
<input type="submit" style="
cursor:pointer;
background: #FFF;
display:inline-block;
height: 40px;
padding: 5px 20px 0 20px;
margin: 0 auto;
-webkit-box-shadow: inset 0px 0px 6px #fff;
border: 1px solid #ccc;
border-radius: 0px;
font: bold 12px Helvetica, Sans-Serif;
text-align: center;
text-transform: none;
text-decoration: none;
color: #000;
background: -o-linear-gradient(top,#FF9900 0% ,#FFF 100%);
background: -moz-linear-gradient(top, #FF9900 0%, #FFF 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#FF9900), color-stop(100%,#FFF));
background: -ms-linear-gradient(top,#FF9900 0% ,#FFF 100%);
background: linear-background(top,#FF9900 0% ,#FFF 100%);
" value="INGRESAR"/>
</td>
</tr>
</table>
<br>
<font size="3" color="#FFF"><b><a href="regist.php">REGISTRAR USUARIO</a></b></font>
</div>
</center>
</div>
</td>
</tr>
</table>
</form>
</center>
</body>
</html>
LISTAADMIN
<?php
session_start();
?>
<!doctype html>
<html lang="es" id="cs">
<head>
<body bgcolor="orange" >
<title>REGISTRO</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="active.php?id=admin" type="text/javascript"></script>
</head>
<body>
<header class="headerproces">
<center><div class="cabecera">
<div id="load">
<div id="bienvenido">
<div style="font-size: 120%"><b>BIENVENIDO</b>::<label id="user" style="color:#000;font-size: 120%">
<?php
if (isset($_SESSION['userRegistro'])){
echo "@".$_SESSION['userRegistro'];
}else{
echo "@sin usuario registrado.com";
}
if (isset($_GET)){
if (isset($_GET['id'])){
include_once("ctr/conexion.php");
$nom=$_GET['id'];
$con=new conexion();
$est=1;
if ($_GET['a']==1)
$est=0;
$datos="update usuario set estusu=$est where nomusu='$nom'";
if(mysql_query($datos,$con->conectar())) {
echo "<br>ACTUALIZACION EXITOSO";
} else
echo "<br>ERROR EN ACTUALIZACION";
}
}
?>
</label><br>
<a href="ctr/endsesion.php?sesion=default"> Cerrar sesión</a>
</div>
</div>
</div>
</header>
<section class="sectionproces">
<center>
<br>
<br>
<table border="1">
<tr>
<td>NOMBRE</td>
<td>ALIAS</td>
<td>EMAIL</td>
<td>NIVEL</td>
<td>ESTADO</td>
</tr>
<?php
include_once("ctr/conexion.php");
$con=new conexion();
$consulta=mysql_query("SELECT * FROM usuario where tipusu<>1",$con->conectar());
while (($registro=mysql_fetch_array($consulta))){
echo "<tr>";
$usu=$registro['nomusu'];
echo "<td>".$registro['nomusu']."</td>";
echo "<td>".$registro['aliusu']."</td>";
echo "<td>".$registro['emausu']."</td>";
echo "<td>".$registro['tipusu']."</td>";
if ($registro['estusu']==0)
echo "<td><a href='listaadmin.php?id=$usu&a=0'>Activar</a></td>";
else
echo "<td><a href='listaadmin.php?id=$usu&a=1'>Desactivar</a></td>";
echo "</tr>";
}
?>
</table>
</center>
</section>
<footer class="footerproces">
</footer>
</center>
</body>
</html>
LISTAUSER
<?php
session_start();
?>
<!doctype html>
<html lang="es" id="cs">
<head>
<title>REGISTRO</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="ctr/active.php?id=admin" type="text/javascript"></script>
</head>
<body>
<header class="headerproces">
<center><div class="cabecera">
<div id="load">
<div id="bienvenido">
<div style="font-size: 120%"><b>BIENVENIDO</b>::<label id="user" style="color:#000;font-size: 120%">
<?php
if (isset($_SESSION['userRegistro'])){
echo "@".$_SESSION['userRegistro'];
}else{
echo "@sin usuario registrado";
}
echo "<br>";
if ($_SESSION['typeuser']!=1){
if ($_SESSION['typeuser']==2){
if ($_SESSION['activo']==0){
echo "USUARIO CONTROL DESACTIVADO";
}else
echo "USUARIO CONTROL ACTIVADO";
}
if ($_SESSION['typeuser']==3){
if ($_SESSION['activo']==0){
echo "USUARIO REGISTRADO DESACTIVADO";
}else
echo "USUARIO REGISTRADO ACTIVADO";
}
if ($_SESSION['typeuser']==4){
if ($_SESSION['activo']==0){
echo "USUARIO INVITADO DESACTIVADO";
}else
echo "USUARIO INVITADO ACTIVADO";
}
}
?>
</label><br>
<a href="ctr/endsesion.php?sesion=default"> Cerrar sesión</a>
</div>
</div>
</div>
</header>
<section class="sectionproces">
</section>
<footer class="footerproces">
</footer>
</center>
</body>
</html>
REGIST
<!doctype html>
<html lang="es" id="cs">
<head>
<body bgcolor="ORANGE" >
<title>TABLA</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<?php
include_once("ctr/conexion.php");
$con=new conexion();
$error="";
if (isset($_POST)){
if (isset($_POST['txtNombre']) && isset($_POST['txtAlias']) && isset($_POST['txtClave']) && isset($_POST['txtRClave']) && isset($_POST['txtEmail'])){
$nombre=$_POST['txtNombre'];
$alias=$_POST['txtAlias'];
$clave=$_POST['txtClave'];
$rclave=$_POST['txtRClave'];
$email=$_POST['txtEmail'];
if ($nombre=="" || $alias=="" || $clave=="" || $rclave=="" || $email=="")
$error="LLENE TODOS LOS DATOAS PARA CONTINUAR";
else{
if ($clave!=$rclave){
$error="LAS CLAVES NO COINCIDEN";
}else{
if ($clave=="" || $rclave=="")
$error="NO SE PUEVE VALIDAD CLAVES EN BLANCO";
else{
$datos="INSERT INTO usuario VALUES('$nombre','$alias','$clave','$email',3,0)";
if(!mysql_query($datos,$con->conectar())) {
$error="No se puedo guardar el docente error desconocido.";
}else
echo "<script>window.location.href='index.php';</script>";
}
}
}
}
}
?>
<form method="POST" action="regist.php">
<table align="center" border="0" style="height: 530px;width: 400px">
<tr >
<td align="center">
<table style="width: 100%; text-align: left" border="0" cellpadding="2px" cellspacing="0px">
<tr>
<td colspan="3"><h1>REGISTRO DE USUARIO</h1></td>
</tr>
<tr>
<td colspan="3"><hr></td>
</tr>
<tr>
<td align="right">Nombres</td>
<td colspan="2"><input name="txtNombre" type="text" value="<?php if(isset($nombre)){echo $nombre;} ?>"/></td>
</tr>
<tr >
<td align="right">Alias</td>
<td colspan="2"><input name="txtAlias" type="text" value="<?php if(isset($alias)){echo $alias;} ?>"/></td>
</tr>
<tr>
<td align="right">Clave</td>
<td colspan="2"><input name="txtClave" type="password" value=""/></td>
</tr>
<tr>
<td align="right">Repita clave</td>
<td colspan="2"><input name="txtRClave" maxlength="15" type="password" value=""/></td>
</tr>
<tr>
<td align="right">E-mail</td>
<td colspan="2"><input name="txtEmail" type="text" value="<?php if(isset($email)){echo $email;} ?>"/>
</td>
</tr>
<tr>
<td colspan="3"><br><center><input type="submit" value="REGISTRAR AHORA"/><center></td>
</tr>
<tr>
<td colspan="3"><br><center><font size="3" color="#FFF"><b><a href="index.php">INICIAR SESION</a></b></font><center></td>
</tr>
<tr>
<td colspan="3"><br><br><center><font size="3" color="RED"><b><?php if(isset($error)){echo $error;} ?></b></font><center></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>
ERROR




















