Ver Mensaje Individual
  #1 (permalink)  
Antiguo 12/04/2008, 12:59
Avatar de pato12
pato12
 
Fecha de Ingreso: septiembre-2007
Ubicación: Salta
Mensajes: 1.620
Antigüedad: 16 años, 7 meses
Puntos: 101
Problema al identificar usuario

Hola,
Estoy haciendo un codigo de autentificason de usuario, funciona bien pero al identificar usuarios que no existen empieza el problema.
Este es el codigo:
Código PHP:
<?php
if($_POST){
session_start();
/////////////////////
$base="---"
$con=mysql_connect('localhost','root',); 
mysql_select_db($base,$con); 
//////////////////////
if($_POST['us']==NULL)echo "<script>location='index.php?mensaje=4'</script>" ;
if(
$_POST['clave']==NULL)echo "<script>location='index.php?mensaje=3&n=$us'</script>" ;
$checkuser mysql_query("SELECT nick FROM users WHERE nick='".$_POST['us']."'",$con) or die(mysql_error());  
$username_exist mysql_num_rows($checkuser) or die(mysql_error());  
$query mysql_query("SELECT nick,clave FROM users WHERE nick = '".$_POST['us']."'",$con) or die(mysql_error()); 
$data mysql_fetch_array($query); 
/////////////////////// 
if($username_exist>0){
if(
$data['clave'] != $_POST['clave'])exit("<script>location='index.php?mensaje=0&n=$us'</script>") ;
session_register('log');
$_SESSION['log']=$_POST['us'];
echo 
"<script>location='op.php'</script>" ;
exit();
}
else{
echo 
"<script>location='index.php?mensaje=1'</script>" ;
}
}
?>
probe tambien haci:
Código PHP:
<?php
if($_POST){
session_start();
/////////////////////
$base="---"
$con=mysql_connect('localhost','root',); 
mysql_select_db($base,$con); 
//////////////////////
if($_POST['us']==NULL)echo "<script>location='index.php?mensaje=4'</script>" ;
if(
$_POST['clave']==NULL)echo "<script>location='index.php?mensaje=3&n=$us'</script>" ;
$checkuser mysql_query("SELECT nick FROM users WHERE nick='".$_POST['us']."'",$con) or die(mysql_error());  
$username_exist mysql_num_rows($checkuser) or die(mysql_error());  
$query mysql_query("SELECT nick,clave FROM users WHERE nick = '".$_POST['us']."'",$con) or die(mysql_error()); 
$data mysql_fetch_array($query); 
/////////////////////// 
if($username_exist>0){
if(
$data['clave'] != $_POST['clave'])exit("<script>location='index.php?mensaje=0&n=$us'</script>") ;
session_register('log');
$_SESSION['log']=$_POST['us'];
echo 
"<script>location='op.php'</script>" ;
exit();
}
//else{
echo "<script>location='index.php?mensaje=1'</script>" ;
//}
}
?>
Pero no me manda a index.php?mensaje=1 ( es usuario no existe ) con ninguno de los 2 codigos.
Gracias
Salu2
__________________
Half Music - www.halfmusic.com