logre hacer que con esto:
Código PHP:
<?
if(!$_COOKIE[uid]) {
?>
CODIGOS DEL LOGIN
<?
}
else {
?>
BIENVENIDA AL USUARIO
<?
}
?>
ahora intento hacer que si un usuario ya logeado intenta ingresar a la direccion de registrarse le salga un mensaje que le diga que ya esta identificado.
Intente con los codigos de arriba pero me da el siguiente error:
Parse error: syntax error, unexpected T_ELSE in C:\xampp\htdocs\PortalTS Design\registrarse1.php on line 204
mi codigo es el siguiente:
Código PHP:
<script>
function revisar() {
if(formulario.nick.value.length < 3) {
alert('El nick debe contener por lo mínimo 3 caractéres.') ;
return false ;
}
if(formulario.nombre.value.length < 1) {
alert('Olvidaste ingresar tu Nombre.') ;
return false ;
}
if(formulario.contrasena.value.length < 6) {
alert('La contraseña debe contener por lo mínimo 6 caractéres.') ;
return false ;
}
if(formulario.contrasena.value != formulario.c_contrasena.value) {
alert('Las contraseñas no son correctas.') ;
return false ;
}
if(!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(formulario.email.value)) {
alert('Debes poner un email válido.') ;
return false ;
}
}
</script>
<title>PortalTS - Design Community</title>
<?php include("incluido.php"); ?>
<div align="center">
<table width="990" height="174" cellspacing="0" cellpadding="0">
<tr>
<td width="100%"></td><td>
<!-- login -->
<?
if(!$_COOKIE[uid]) {
?>
<form method="post" action="ingresando.php">
<table cellpadding="3" cellspacing="0">
<tr><td><font color="#c9ecf6" size="1"> <b>USUARIO:</b></font></td><td><font color="#c9ecf6" size="1"> <b>PASSWORD:</b></font></td><td></td></tr>
<tr><td><div class="input_d"><input type="text" name="nick" maxlength="20"></div></td><td><div class="input_d"><input type="password" name="contrasena" maxlength="20"></div></td><td><div id="login_d"><input type="submit" name="enviar" value="Iniciar Sesión"></div></td></tr>
</td></tr>
<tr><td colspan="3"><font size="1" color="#d4d4d4"> <a href="#" class="logo">¿Olvidaste tu contraseña?</a> l <label for="cb_cookieuser_navbar">Recordarme <input type="checkbox" name="option1" value="send"></label>
</table></form>
<?
}
else {
?>
<table cellpadding="3" cellspacing="0" width="300">
<tr><td><font size="1" color="#ffffff"><div align="center">Bienvenido/a <b><?=$_COOKIE[unick]?></b></div></td></tr>
<tr><td><div align="center"><font size="1" color="#d4d4d4"><a href="salir.php" class="logo">Cerrar Sesión</a></font></div></td></tr>
</table>
<?
}
?>
<!-- fin login --></td>
</tr>
</table>
<table class="navegacion" cellspacing="0" cellpadding="2" border="0" width="990" align="center">
<?php include("navegacion.php"); ?>
<tr>
<td colspan="7" style="background: #16233a;">
<table width="100%" cellspacing="0" cellpadding="10">
<tr>
<td>
<div align="center">
<table cellpadding="0" cellspacing="0" border="0">
<tr><td><img src="images/top_bar.jpg"></td></tr>
<tr><td class="tdcontenido">
<?
if(!$_COOKIE[uid]) {
?>
<div style="padding-top:10px;padding-left:10px;padding-bottom:5px;"><img src="images/registro.png"></div><br>
<!-- registrar -->
<div align="center">
<form name="formulario" method="post" action="<?=$_SERVER[PHP_SELF]?>" onsubmit="return revisar()">
<table cellpadding="7" border="0" height="1">
<tr>
<td colspan="3">
<?
if($_POST[enviar]) {
require 'config.php' ;
function quitar($texto) {
$texto = trim($texto) ;
$texto = htmlspecialchars($texto) ;
$texto = str_replace(chr(160),'',$texto) ; # Elimina espacios que no pueden ser borrados por trim()
return $texto ;
}
$nick = quitar($_POST[nick]) ;
$email = quitar($_POST[email]) ;
$con = mysql_query("select count(id) from usuarios where nick='$nick' or email='$email'") ;
if(mysql_result($con,0,0)) {
echo '<br><div align="center"><font size="2" color="#ffffff"><b>Al parecer el nick o email que elegiste ya estan siendo usados.</b></font></div><br><div align="center"><font size="1" color="#a0a0a0">Haz click <a class="logo" href="javascript:history.back(-1)">aquí</a> para regresar.</font></div><br>' ;
}
else {
$fecha = time() ;
$contrasena = md5(md5(quitar($_POST[contrasena]))) ;
$nombre = quitar($_POST[nombre]);
$n_dia = quitar($_POST[n_dia]);
$n_mes = quitar($_POST[n_mes]);
$n_ano = quitar($_POST[n_ano]);
mysql_query("insert into usuarios (fecha,nick,contrasena,email,ip,n_dia,n_mes,n_ano,nombre) values ('$fecha','$nick','$contrasena','$email','$_SERVER[REMOTE_ADDR]','$n_dia','$n_mes','$n_ano','$nombre')") ;
echo '<br><div align="center"><font size="2" color="#ffffff"><b>Has sido registrado/a satisfactoriamente!</b></font></div><br><div align="center"><font size="1" color="#a0a0a0">Haz click <a href="index.php" class="logo">aquí</a> para regresar a la página principal e iniciar sesión</font></div><br>' ;
}
}
else {
?>
<font color="#a0a0a0" size="1">Al registrarte en PortalTS, tendrás acceso a nuestro contenido en su totalidad, tendrás una sección exclusiva para nuestros miembros, foro, entre otros beneficios.</font></td></tr>
<tr>
<td>
<div align="center"><table cellpadding="9">
<tr><td colspan="3"><font color="white" size="2"><b>Datos de la Cuenta</b></font></td></tr>
<tr>
<td width="210" height="1"><font color="white" size="2"> Usuario:</font></td>
<td width="210" height="1"><div class="input_c"><input type="text" name="nick" maxlength="20"></div></td><td><div align="left"><font color="#a0a0a0" size="1">*Campo obligatorio</font></div></td>
</tr>
<tr>
<td width="210" height="1"><font color="white" size="2"> Password:</font></td>
<td width="210" height="1"><div class="input_c"><input type="password" name="contrasena" maxlength="10"></div></td><td><div align="left"><font color="#a0a0a0" size="1">*Campo obligatorio</font></div></td>
</tr>
<tr>
<td width="210" height="1"><font color="white" size="2"> Confirmar Password:</font></td>
<td width="210" height="1"><div class="input_c"><input type="password" name="c_contrasena" maxlength="10"></div></td><td><div align="left"><font color="#a0a0a0" size="1">*Campo obligatorio</font></div></td>
</tr>
<tr><td colspan="3"><div style="padding-top:10px;"><font color="white" size="2"><b>Datos Personales</b></font></div></td></tr>
<tr>
<td width="210" height="1"><font color="white" size="2"> Nombres y Apellidos:</font></td>
<td width="210" height="1"><div class="input_c"><input type="text" name="nombre" maxlength="50"></div></td><td><div align="left"><font color="#a0a0a0" size="1">*Campo obligatorio</font></div></td>
</tr>
<tr>
<td><font color="white" size="2"> Fecha de Nacimiento:</font></td>
<td>
QUITE ESTO POR ESPACIO
</td>
</tr>
<tr>
<td width="210" height="1"><font color="white" size="2"> Email:</font></td>
<td width="210" height="1"><div class="input_c"><input type="text" name="email" maxlength="40"></div></td><td><div align="left"><font color="#a0a0a0" size="1">*Campo obligatorio</font></div></td>
</tr>
<tr>
<td height="1" colspan="3">
<div align="center" style="padding-top:10px;"><input type="submit" name="enviar" value="Registrar"> <input type="reset" value="Restablecer"></div></td>
</tr>
</table></div>
</td>
</tr>
</table>
</form>
<!-- fin registrar --></div>
<?
}
else {
?><td align="center"><font size="1">Ya estas regitrado</td>
<?
}
?>
</td></tr></table>
</div>
</td></tr>
</table>
</td>
</tr>
</table>
</div>
<?
}
?>
Espero que me puedan ayudar