20, March 2010

Error trying to login and logout - webmaster forum

 
Webdigity webmaster forums
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP  >  Php User Class
Topic: Error trying to login and logout
« previous next »
Pages: [1] Print

Author Topic: Error trying to login and logout  (Read 1539 times)
Google dot what?
*
Posts: 2
16 credits
Members referred : 0


« on: Apr 01, 2009, 09:18:19 pm »

Hello

Im trying to install this class on my website but im getting some problemas, i got a login form and when the user login and click on submit the user is taken to: login.php?exito=1 and it supposed to the user sending to the main website becasue on login.php i got this:

Code:
    if(!empty($_POST["usuario"]))
{
  sleep(2); //only for debug
 
  //Super rutina de seguridad para la comprobación de usuarios
  if($user->login($_POST['usuario'],$_POST['clave'],$_POST['recordar'] ))
  {
    echo "OK!"; //Dato clave, de esto depende el Formulario AJAX
  }
  else
  {
    echo "NO!"; //Dato clave, de esto depende el Formulario AJAX
  }

}
elseif ((bool) $_GET['exito'])
{
  if($user->is_loaded()){ header('Location: http://www.mainwebsite.com'); }else{ include 'login_template.html'; }
}
else
{
  include("login_template.html");
}

and also i got a problem trying to logout, i got headers already sent error, and i not sending anything...sorry my bad english hope you can help me.
« Last Edit: Apr 01, 2009, 09:21:55 pm by lucasvm »
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5659
45587 credits
Members referred : 3



« Reply #1 on: Apr 02, 2009, 07:54:50 am »

The first part (that echoes OK or NO) is why no header can't be sent. Remove this, and if you still have problems please repost with your php.ini file. It seems that there is some kind of session problem with some strange configuration which we haven't found yet.


Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Google dot what?
*
Posts: 2
16 credits
Members referred : 0


« Reply #2 on: Apr 02, 2009, 11:58:07 pm »

ok, error solved, there was a programing error...sorry, i got another question, in my register page y got this code:

Code:
if($_POST){
if((!$_POST['usuario'])OR(!$_POST['email'])OR(!$_POST['clave'])){ // Verificamos que no se quede ningun campo vacio...
echo '<p>No deje ningun campo en blanco, intente de nuevo...</p>';
}else{
if(!eregi("^[a-z0-9_-]+$", $_POST['usuario'])){ // Verificamos que el usuario tenga solo letras, numeros y guiones...
echo '<p>El usuario solo puede contener letras, numeros y guiones, intente de nuevo...</p>';
}else{
if(!eregi("^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,4}$", $_POST['email'])) { // Verificamos que el correo sea valido...
echo '<p>El correo electronico no es valido, intente con un correo verdadero...</p>';
}else{
$data = array(
'usuario' => $_POST['usuario'],
'email' => $_POST['email'],
'clave' => $_POST['clave'],
'ubicacion' => $_POST['ubicacion'],
'web' => $_POST['web'],
'mensaje' => $_POST['mensaje'],
'usuario' => $_POST['usuario'],
'avatar' => $_POST['avatar'],
'msn' => $_POST['msn'],
'activacion' => 1
);
 $userID = $user->insertUser($data);//The method returns the userID of the new user or 0 if the user is not added
 if ($userID==0)
  echo 'Usuario ya utilizado, intente con otro nombre';//user is allready registered or something like that
 else
  echo 'User registered with user id <ingresar.php>iniciar sesion</a>.</p>'.$userID;
}
  $dest = $_POST['email'];
      $head = "From: no-contestar\r\n";
      $head.= "To: ".$_POST['email']."\r\n";
      $msg = "Te has registrado correctamente en nuestro sitio, estos son tus datos: \n";
      $msg.= "Usuario: ".$_POST['usuario']." \n";
      $msg.= "Clave: ".$_POST['clave']." \n";
      $msg.= "Para iniciar sesion ve a ingresar.php \n";
      mail($dest, "Confirmacion de registro", $msg, $head);

}
} // Termina verificacion de: $_POST['email']
} // Termina verificacion de: $_POST['usuario']
} // Termina verificacion de: $_POST['']

is there a way to know if the user is already register?, because if i register a user with the same name there is no error message or whatever and it record the user, and it shouldnt, what can i do?HuhHuhHuh, any ideas?

I have made a great ajax user check to know if the user is already registered, it works fantastic but still the phpuserclass let me record the user, how can i do&#191;?

i got this ajax script that control:

Code:
include("conexio.php"); 
$nick=$_REQUEST['nick'];
$consulta= mysql_query("SELECT * FROM table WHERE field='$nick'"); 
if(mysql_num_rows($consulta)>0) 
echo "$nick already in use"; 
else echo "Username Available"; 

This works great!!, it is possible to use it with phpuserclass? IT WOULD BE FANTASTIC
« Last Edit: Apr 03, 2009, 12:42:28 am by lucasvm »
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=8638
Tags : fgdf Bookmark this thread : Digg Del.icio.us Dzone more....

Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP  >  Php User Class
Topic: Error trying to login and logout
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
Mar 20, 2010, 05:56:06 am





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!





Readers

Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2010 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.