Foros del Web » Programando para Internet » PHP »

Error en Sistema de recuperación de contraseña.

Estas en el tema de Error en Sistema de recuperación de contraseña. en el foro de PHP en Foros del Web. Estimado(a)s Buscando en internet me encontre un código que me parecio muy bueno y desee probarlo. Fuente: [URL="http://www.evolt.org/node/60384"]http://www.evolt.org/node/60384[/URL] Cuando intente usarlo en mi pc local ...
  #1 (permalink)  
Antiguo 03/03/2011, 06:35
 
Fecha de Ingreso: julio-2005
Mensajes: 26
Antigüedad: 18 años, 9 meses
Puntos: 0
Pregunta Error en Sistema de recuperación de contraseña.

Estimado(a)s

Buscando en internet me encontre un código que me parecio muy bueno y desee probarlo.

Fuente: [URL="http://www.evolt.org/node/60384"]http://www.evolt.org/node/60384[/URL]

Cuando intente usarlo en mi pc local la sección donde dice [Forgot Password?] no me envia la clave de usuario me da el siguiente error:

Código:
Fatal error: Call to a member function sendNewPass() on a non-object in \process.php on line 159
Podría alguno de ustedes explicarme que esta mal.

Sin más en espera de sus comentarios y respuestas.

Saludos cordiales.
  #2 (permalink)  
Antiguo 03/03/2011, 06:39
Colaborador
 
Fecha de Ingreso: octubre-2009
Ubicación: Tokyo - Japan !
Mensajes: 3.867
Antigüedad: 14 años, 6 meses
Puntos: 334
Respuesta: Error en Sistema de recuperación de contraseña.

deberías pegar el código...
donde aparezca la linea 159 del archivo process.php..


saludos.
  #3 (permalink)  
Antiguo 03/03/2011, 06:48
 
Fecha de Ingreso: julio-2005
Mensajes: 26
Antigüedad: 18 años, 9 meses
Puntos: 0
Pregunta Respuesta: Error en Sistema de recuperación de contraseña.

Estimado(a)s

Aqui esta el código completo de la pagina process.php les puse un aviso con doble barra invertida ( // ) para que sepan donde esta la linea 159.

Código PHP:
<?
/**
 * Process.php
 * 
 * la tarea de esto es prosesar la info del usuario
 * y redirecionarlo al lugar correcto
 * tambien prosesa errores
 *
 * Login System By lil fino
 * Creado el 5 de abril del 2010
 * Mantenga esta noticia intacta
 * por futuras actualizaciones
*/
include("include/session.php");

class 
Process
{
   
/* Class constructor */
   
function Process(){
      global 
$session;
     
/*user puso el login form */
      
if(isset($_POST['sublogin'])){
         
$this->procLogin();
      }
      
/* User puso la rejistracion */
      
else if(isset($_POST['subjoin'])){
         
$this->procRegister();
      }
      
/* User puso que olvideo la contrasena */
      
else if(isset($_POST['subforgot'])){
         
$this->procForgotPass();
      }
      
/* User puso editir cuenta */
      
else if(isset($_POST['subedit'])){
         
$this->procEditAccount();
      }
      
/**
       * la unica razon por la cual el usuario sera 
       * redirecionado aqui es por que quiere salirse
       */
      
else if($session->logged_in){
         
$this->procLogout();
      }
      
/**
       * si no deveria estar aqui sera redirecionado a la pagina principal
       */
       
else{
          
header("Location: main.php");
       }
   }

   
/**
    * procLogin - prosesa la informacion que puso el usuario
    * para iniciar seccion y su ubo algun error sera redirecionado
    */
   
function procLogin(){
      global 
$session$form;
      
/* Login attempt */
      
$retval $session->login($_POST['user'], $_POST['pass'], isset($_POST['remember']));
      
      
/* Login susesivamente */
      
if($retval){
         
header("Location: ".$session->referrer);
      }
      
/* Login fallo */
      
else{
         
$_SESSION['value_array'] = $_POST;
         
$_SESSION['error_array'] = $form->getErrorArray();
         
header("Location: ".$session->referrer);
      }
   }
   
   
/**
    * procLogout - Simplemente saca el usuario del systema
    */
   
function procLogout(){
      global 
$session;
      
$retval $session->logout();
      
header("Location: main.php");
   }
   
   
/**
    * procRegister - Procesa lo que aiga puesto el usuario
    * si se encuentran errores el usuario es redirecionado a correjirlos.
    */
   
function procRegister(){
      global 
$session$form;
      
/* Convert username to all lowercase (by option) */
      
if(ALL_LOWERCASE){
         
$_POST['user'] = strtolower($_POST['user']);
      }
      
/* intento de rejistracion */
      
$retval $session->register($_POST['user'], $_POST['pass'], $_POST['email']);
      
      
/* Registracion susesivamente */
      
if($retval == 0){
         
$_SESSION['reguname'] = $_POST['user'];
         
$_SESSION['regsuccess'] = true;
         
header("Location: ".$session->referrer);
      }
      
/* Error encontrados en el formulario */
      
else if($retval == 1){
         
$_SESSION['value_array'] = $_POST;
         
$_SESSION['error_array'] = $form->getErrorArray();
         
header("Location: ".$session->referrer);
      }
      
/* intento rejistracion fallo */
      
else if($retval == 2){
         
$_SESSION['reguname'] = $_POST['user'];
         
$_SESSION['regsuccess'] = false;
         
header("Location: ".$session->referrer);
      }
   }
   
   
/**
    * procForgotPass - Valida el nombre de usuario y si todo esta bien
    * una nueva contrasena es generada
    * y se mandara un correo al usuario 
    */
   
function procForgotPass(){
      global 
$database$session$mailer$form;
      
/* Username error checking */
      
$subuser $_POST['user'];
      
$field "user";  //Use field name for username
      
if(!$subuser || strlen($subuser trim($subuser)) == 0){
         
$form->setError($field"* Username not entered<br>");
      }
      else{
         
/* se asegura que el nombre este en la base de datos */
         
$subuser stripslashes($subuser);
         if(
strlen($subuser) < || strlen($subuser) > 30 ||
            !
eregi("^([0-9a-z])+$"$subuser) ||
            (!
$database->usernameTaken($subuser))){
            
$form->setError($field"* Username does not exist<br>");
         }
      }
      
      
/* existe un error, que el usuario los corrija */
      
if($form->num_errors 0){
         
$_SESSION['value_array'] = $_POST;
         
$_SESSION['error_array'] = $form->getErrorArray();
      }
      
      else{
         
/* Genera nueva contrasena */
         
$newpass $session->generateRandStr(8);
         
         
/* agarra el correo del usuario */
         
$usrinf $database->getUserInfo($subuser);
         
$email  $usrinf['email'];
         
         
/* manda el correo con la nueva contrasena */
         
if($mailer->sendNewPass($subuser,$email,$newpass)){
            
/* correo enviado, actualiza la base de datos */
            
$database->updateUserField($subuser"password"md5($newpass));
            
$_SESSION['forgotpass'] = true;
         }
         
/* correo fallo, no cambiara la contrasena */
   
else{ // LINEA 159, AQUI ES DONDE ESTA EL ERROR QUE DICE!!!
            
$_SESSION['forgotpass'] = false;
         }
      }
      
      
header("Location: ".$session->referrer);
   }
   
   
/**
    * procEditAccount - edita la cuenta del usuario incuyendo la 
    * contrasena la cual sera verificada antes de cambiar
    */
   
function procEditAccount(){
      global 
$session$form;
      
/* intentando editir la cuenta */
      
$retval $session->editAccount($_POST['curpass'], $_POST['newpass'], $_POST['email']);

      
/* edicion susesivamente */
      
if($retval){
         
$_SESSION['useredit'] = true;
         
header("Location: ".$session->referrer);
      }
      
/* ubo un error */
      
else{
         
$_SESSION['value_array'] = $_POST;
         
$_SESSION['error_array'] = $form->getErrorArray();
         
header("Location: ".$session->referrer);
      }
   }
};

/* Inicia el proseso */
$process = new Process;

?>
Espero que me puedan ayudar.

Saludos.
  #4 (permalink)  
Antiguo 03/03/2011, 08:15
 
Fecha de Ingreso: noviembre-2007
Mensajes: 382
Antigüedad: 16 años, 4 meses
Puntos: 16
Respuesta: Error en Sistema de recuperación de contraseña.

se me ocurre que: o no tienes creado el objeto $mailer o no tienes el servidor local preparado para mandar emails.

por el código parece lo primero, no hay ningún $mailer=new Nombre_clase(...), pero no tener el local preparado para mandar mails suele ser un fallo bastante común.

A ver si te sirve :)
  #5 (permalink)  
Antiguo 03/03/2011, 08:44
Usuario no validado
 
Fecha de Ingreso: mayo-2005
Ubicación: Benicàssim
Mensajes: 56
Antigüedad: 18 años, 10 meses
Puntos: 0
Respuesta: Error en Sistema de recuperación de contraseña.

Hola!
Confirmame sin DENTRO de este archivo
Cita:
include("include/session.php")
tienes la FUNCION sendNewPass() y que el archivo está ubicado en lugar que declaras en INCLUDE.
  #6 (permalink)  
Antiguo 03/03/2011, 08:56
 
Fecha de Ingreso: julio-2005
Mensajes: 26
Antigüedad: 18 años, 9 meses
Puntos: 0
Pregunta Respuesta: Error en Sistema de recuperación de contraseña.

Estimado manzarinaa.

Mira este es el codigo de la pagina web session.php

Código PHP:
<?
/**
 * Session.php
 * 
 * The Session class is meant to simplify the task of keeping
 * track of logged in users and also guests.
 *
 * Written by: Jpmaster77 a.k.a. The Grandmaster of C++ (GMC)
 * Last Updated: August 19, 2004
 */
include("database.php");
include(
"mailer.php");
include(
"form.php");
//include("phpmailer.php");
class Session
{
   var 
$username;     //Username given on sign-up
   
var $userid;       //Random value generated on current login
   
var $userlevel;    //The level to which the user pertains
   
var $time;         //Time user was last active (page loaded)
   
var $logged_in;    //True if user is logged in, false otherwise
   
var $userinfo = array();  //The array holding all user info
   
var $url;          //The page url current being viewed
   
var $referrer;     //Last recorded site page viewed
   /**
    * Note: referrer should really only be considered the actual
    * page referrer in process.php, any other time it may be
    * inaccurate.
    */
   /* Class constructor */
   
function Session(){
      
$this->time time();
      
$this->startSession();
   }
   
/**
    * startSession - Performs all the actions necessary to 
    * initialize this session object. Tries to determine if the
    * the user has logged in already, and sets the variables 
    * accordingly. Also takes advantage of this page load to
    * update the active visitors tables.
    */
   
function startSession(){
      global 
$database;  //The database connection
      
session_start();   //Tell PHP to start the session
      /* Determine if user is logged in */
      
$this->logged_in $this->checkLogin();
      
/**
       * Set guest value to users not logged in, and update
       * active guests table accordingly.
       */
      
if(!$this->logged_in){
         
$this->username $_SESSION['username'] = GUEST_NAME;
         
$this->userlevel GUEST_LEVEL;
         
$database->addActiveGuest($_SERVER['REMOTE_ADDR'], $this->time);
      }
      
/* Update users last active timestamp */
      
else{
         
$database->addActiveUser($this->username$this->time);
      }
      
/* Remove inactive visitors from database */
      
$database->removeInactiveUsers();
      
$database->removeInactiveGuests();
      
/* Set referrer page */
      
if(isset($_SESSION['url'])){
         
$this->referrer $_SESSION['url'];
      }else{
         
$this->referrer "/";
      }
      
/* Set current url */
      
$this->url $_SESSION['url'] = $_SERVER['PHP_SELF'];
   }
  
/**
    * checkLogin - Checks if the user has already previously
    * logged in, and a session with the user has already been
    * established. Also checks to see if user has been remembered.
    * If so, the database is queried to make sure of the user's 
    * authenticity. Returns true if the user has logged in.
    */
   
function checkLogin(){
      global 
$database;  //The database connection
      /* Check if user has been remembered */
      
if(isset($_COOKIE['cookname']) && isset($_COOKIE['cookid'])){
         
$this->username $_SESSION['username'] = $_COOKIE['cookname'];
         
$this->userid   $_SESSION['userid']   = $_COOKIE['cookid'];
      }
     
/* Username and userid have been set and not guest */
      
if(isset($_SESSION['username']) && isset($_SESSION['userid']) &&
         
$_SESSION['username'] != GUEST_NAME){
         
/* Confirm that username and userid are valid */
         
if($database->confirmUserID($_SESSION['username'], $_SESSION['userid']) != 0){
            
/* Variables are incorrect, user not logged in */
            
unset($_SESSION['username']);
            unset(
$_SESSION['userid']);
            return 
false;
         }
         
/* User is logged in, set class variables */
         
$this->userinfo  $database->getUserInfo($_SESSION['username']);
         
$this->username  $this->userinfo['username'];
         
$this->userid    $this->userinfo['userid'];
         
$this->userlevel $this->userinfo['userlevel'];
         return 
true;
      }
      
/* User not logged in */
      
else{
         return 
false;
      }
   }
   
/**
    * login - The user has submitted his username and password
    * through the login form, this function checks the authenticity
    * of that information in the database and creates the session.
    * Effectively logging in the user if all goes well.
    */
   
function login($subuser$subpass$subremember){
      global 
$database$form;  //The database and form object
      /* Username error checking */
      
$field "user";  //Use field name for username
      
if(!$subuser || strlen($subuser trim($subuser)) == 0){
         
$form->setError($field"* Usuario no existe.");
      }
      else{
         
/* Check if username is not alphanumeric */
         
if(!eregi("^([0-9a-z])*$"$subuser)){
            
$form->setError($field"* Nombre de usuario no alfanumérico.");
         }
      }
      
/* Password error checking */
      
$field "pass";  //Use field name for password
      
if(!$subpass){
         
$form->setError($field"* Contraseña no existe.");
      }
     
/* Return if form errors exist */
      
if($form->num_errors 0){
         return 
false;
      }
      
/* Checks that username is in database and password is correct */
      
$subuser stripslashes($subuser);
      
$result $database->confirmUserPass($subusermd5($subpass));
      
/* Check error codes */
      
if($result == 1){
         
$field "user";
         
$form->setError($field"* Usuario no encontrado.");
      }
      else if(
$result == 2){
         
$field "pass";
         
$form->setError($field"* Contraseña no valida.");
      }
      
/* Return if form errors exist */
      
if($form->num_errors 0){
         return 
false;
      }
      
/* Username and password correct, register session variables */
      
$this->userinfo  $database->getUserInfo($subuser);
      
$this->username  $_SESSION['username'] = $this->userinfo['username'];
      
$this->userid    $_SESSION['userid']   = $this->generateRandID();
      
$this->userlevel $this->userinfo['userlevel'];
     
/* Insert userid into database and update active users table */
      
$database->updateUserField($this->username"userid"$this->userid);
      
$database->addActiveUser($this->username$this->time);
      
$database->removeActiveGuest($_SERVER['REMOTE_ADDR']);
      
/**
       * This is the cool part: the user has requested that we remember that
       * he's logged in, so we set two cookies. One to hold his username,
       * and one to hold his random value userid. It expires by the time
       * specified in constants.php. Now, next time he comes to our site, we will
       * log him in automatically, but only if he didn't log out before he left.
       */
      
if($subremember){
         
setcookie("cookname"$this->usernametime()+COOKIE_EXPIRECOOKIE_PATH);
         
setcookie("cookid",   $this->userid,   time()+COOKIE_EXPIRECOOKIE_PATH);
      }
      
/* Login completed successfully */
      
return true;
   }
   
/**
    * logout - Gets called when the user wants to be logged out of the
    * website. It deletes any cookies that were stored on the users
    * computer as a result of him wanting to be remembered, and also
    * unsets session variables and demotes his user level to guest.
    */
   
function logout(){
      global 
$database;  //The database connection
      /**
       * Delete cookies - the time must be in the past,
       * so just negate what you added when creating the
       * cookie.
       */
      
if(isset($_COOKIE['cookname']) && isset($_COOKIE['cookid'])){
         
setcookie("cookname"""time()-COOKIE_EXPIRECOOKIE_PATH);
         
setcookie("cookid",   ""time()-COOKIE_EXPIRECOOKIE_PATH);
      }
      
/* Unset PHP session variables */
      
unset($_SESSION['username']);
      unset(
$_SESSION['userid']);
      
/* Reflect fact that user has logged out */
      
$this->logged_in false;
      
/**
       * Remove from active users table and add to
       * active guests tables.
       */
      
$database->removeActiveUser($this->username);
      
$database->addActiveGuest($_SERVER['REMOTE_ADDR'], $this->time);
      
      
/* Set user level to guest */
      
$this->username  GUEST_NAME;
      
$this->userlevel GUEST_LEVEL;
   }
Como no me cabe todo escribo la segunda parte en otro mensaje.

En espera de su respuesta un saludo.
  #7 (permalink)  
Antiguo 03/03/2011, 08:59
 
Fecha de Ingreso: julio-2005
Mensajes: 26
Antigüedad: 18 años, 9 meses
Puntos: 0
Pregunta Respuesta: Error en Sistema de recuperación de contraseña.

Aqui esta la segunda parte del código de session.php
Código PHP:
   /**
    * register - Gets called when the user has just submitted the
    * registration form. Determines if there were any errors with
    * the entry fields, if so, it records the errors and returns
    * 1. If no errors were found, it registers the new user and
    * returns 0. Returns 2 if registration failed.
    */
   
function register($subuser$subpass$subemail){
      global 
$database$form$mailer;  //The database, form and mailer object
      
      /* Username error checking */
      
$field "user";  //Use field name for username
      
if(!$subuser || strlen($subuser trim($subuser)) == 0){
         
$form->setError($field"* Usuario no existe.");
      }
      else{
         
/* Spruce up username, check length */
         
$subuser stripslashes($subuser);
         if(
strlen($subuser) < 5){
            
$form->setError($field"* Nombre de usuario por debajo de 5 caracteres.");
         }
         else if(
strlen($subuser) > 30){
            
$form->setError($field"* Nombre de usuario superior a 30 caracteres.");
         }
         
/* Check if username is not alphanumeric */
         
else if(!eregi("^([0-9a-z])+$"$subuser)){
            
$form->setError($field"* Nombre de usuario no alfanumérico.");
         }
         
/* Check if username is reserved */
         
else if(strcasecmp($subuserGUEST_NAME) == 0){
            
$form->setError($field"* Nombre de usuario con palabras reservadas.");
         }
         
/* Check if username is already in use */
         
else if($database->usernameTaken($subuser)){
            
$form->setError($field"* Nombre de usuario ya está en uso.");
         }
         
/* Check if username is banned */
         
else if($database->usernameBanned($subuser)){
            
$form->setError($field"* Nombre de usuario prohibido.");
         }
      }

      
/* Password error checking */
      
$field "pass";  //Use field name for password
      
if(!$subpass){
         
$form->setError($field"* Contraseña no existe.");
      }
      else{
         
/* Spruce up password and check length*/
         
$subpass stripslashes($subpass);
         if(
strlen($subpass) < 4){
            
$form->setError($field"* Contraseña muy corta");
         }
         
/* Check if password is not alphanumeric */
         
else if(!eregi("^([0-9a-z])+$", ($subpass trim($subpass)))){
            
$form->setError($field"* Contraseña no alfanumérico.");
         }
         
/**
          * Note: I trimmed the password only after I checked the length
          * because if you fill the password field up with spaces
          * it looks like a lot more characters than 4, so it looks
          * kind of stupid to report "password too short".
          */
      
}
      
      
/* Email error checking */
      
$field "email";  //Use field name for email
      
if(!$subemail || strlen($subemail trim($subemail)) == 0){
         
$form->setError($field"* Email no existe.");
      }
      else{
         
/* Check if valid email address */
         
$regex "^[_+a-z0-9-]+(\.[_+a-z0-9-]+)*"
                 
."@[a-z0-9-]+(\.[a-z0-9-]{1,})*"
                 
."\.([a-z]{2,}){1}$";
         if(!
eregi($regex,$subemail)){
            
$form->setError($field"* Email incorrecto.");
         }
         
$subemail stripslashes($subemail);
      }

      
/* Errors exist, have user correct them */
      
if($form->num_errors 0){
         return 
1;  //Errors with form
      
}
      
/* No errors, add the new account to the */
      
else{
         if(
$database->addNewUser($subusermd5($subpass), $subemail)){
            if(
EMAIL_WELCOME){
               
$mailer->sendWelcome($subuser,$subemail,$subpass);
            }
            return 
0;  //New user added succesfully
         
}else{
            return 
2;  //Registration attempt failed
         
}
      }
   }
   
   
/**
    * editAccount - Attempts to edit the user's account information
    * including the password, which it first makes sure is correct
    * if entered, if so and the new password is in the right
    * format, the change is made. All other fields are changed
    * automatically.
    */
   
function editAccount($subcurpass$subnewpass$subemail){
      global 
$database$form;  //The database and form object
      /* New password entered */
      
if($subnewpass){
         
/* Current Password error checking */
         
$field "curpass";  //Use field name for current password
         
if(!$subcurpass){
            
$form->setError($field"* Contraseña actual no entró.");
         }
         else{
            
/* Check if password too short or is not alphanumeric */
            
$subcurpass stripslashes($subcurpass);
            if(
strlen($subcurpass) < ||
               !
eregi("^([0-9a-z])+$", ($subcurpass trim($subcurpass)))){
               
$form->setError($field"* Contraseña actual incorrecta.");
            }
            
/* Password entered is incorrect */
            
if($database->confirmUserPass($this->username,md5($subcurpass)) != 0){
               
$form->setError($field"* Contraseña actual incorrecta.");
            }
         }
         
         
/* New Password error checking */
         
$field "newpass";  //Use field name for new password
         /* Spruce up password and check length*/
         
$subpass stripslashes($subnewpass);
         if(
strlen($subnewpass) < 4){
            
$form->setError($field"* Nueva contraseña demasiado corta.");
         }
         
/* Check if password is not alphanumeric */
         
else if(!eregi("^([0-9a-z])+$", ($subnewpass trim($subnewpass)))){
            
$form->setError($field"* Nueva contraseña no alfanumérica.");
         }
      }
      
/* Change password attempted */
      
else if($subcurpass){
         
/* New Password error reporting */
         
$field "newpass";  //Use field name for new password
         
$form->setError($field"* Nueva contraseña no entró.");
      }
      
      
/* Email error checking */
      
$field "email";  //Use field name for email
      
if($subemail && strlen($subemail trim($subemail)) > 0){
         
/* Check if valid email address */
         
$regex "^[_+a-z0-9-]+(\.[_+a-z0-9-]+)*"
                 
."@[a-z0-9-]+(\.[a-z0-9-]{1,})*"
                 
."\.([a-z]{2,}){1}$";
         if(!
eregi($regex,$subemail)){
            
$form->setError($field"* Email invalido.");
         }
         
$subemail stripslashes($subemail);
      }
      
      
/* Errors exist, have user correct them */
      
if($form->num_errors 0){
         return 
false;  //Errors with form
      
}
      
      
/* Update password since there were no errors */
      
if($subcurpass && $subnewpass){
         
$database->updateUserField($this->username,"password",md5($subnewpass));
      }
      
      
/* Change Email */
      
if($subemail){
         
$database->updateUserField($this->username,"email",$subemail);
      }
      
      
/* Success! */
      
return true;
   }
   
   
/**
    * isAdmin - Returns true if currently logged in user is
    * an administrator, false otherwise.
    */
   
function isAdmin(){
      return (
$this->userlevel == ADMIN_LEVEL ||
              
$this->username  == ADMIN_NAME);
   }
   
   
/**
    * generateRandID - Generates a string made up of randomized
    * letters (lower and upper case) and digits and returns
    * the md5 hash of it to be used as a userid.
    */
   
function generateRandID(){
      return 
md5($this->generateRandStr(16));
   }
   
   
/**
    * generateRandStr - Generates a string made up of randomized
    * letters (lower and upper case) and digits, the length
    * is a specified parameter.
    */
   
function generateRandStr($length){
      
$randstr "";
      for(
$i=0$i<$length$i++){
         
$randnum mt_rand(0,61);
         if(
$randnum 10){
            
$randstr .= chr($randnum+48);
         }else if(
$randnum 36){
            
$randstr .= chr($randnum+55);
         }else{
            
$randstr .= chr($randnum+61);
         }
      }
      return 
$randstr;
   }
};


/**
 * Initialize session object - This must be initialized before
 * the form object because the form uses session variables,
 * which cannot be accessed unless the session has started.
 */
$session = new Session;

/* Initialize form object */
$form = new Form;

?> 
Espero me puedan decir donde estar el error.

Saludos.
  #8 (permalink)  
Antiguo 03/03/2011, 09:02
 
Fecha de Ingreso: julio-2005
Mensajes: 26
Antigüedad: 18 años, 9 meses
Puntos: 0
Pregunta Respuesta: Error en Sistema de recuperación de contraseña.

Aqui tambien les paso la clase mailer.php

Código PHP:
<? 
/**
 * Mailer.php
 *
 * The Mailer class is meant to simplify the task of sending
 * emails to users. Note: this email system will not work
 * if your server is not setup to send mail.
 *
 * If you are running Windows and want a mail server, check
 * out this website to see a list of freeware programs:
 * <http://www.snapfiles.com/freeware/server/fwmailserver.html>
 *
 * Written by: Jpmaster77 a.k.a. The Grandmaster of C++ (GMC)
 * Last Updated: August 19, 2004
 */
 
class Mailer
{
   
/**
    * sendWelcome - Sends a welcome message to the newly
    * registered user, also supplying the username and
    * password.
    */
   
function sendWelcome($user$email$pass){
      
$from "From: ".EMAIL_FROM_NAME." <".EMAIL_FROM_ADDR.">";
      
$subject "INTRANET - AEROJET SA - Bienvenido(a)!";
      
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
      
$body $user.",\n\n"
             
."Bienvenido(a)! Usted se ha registrado en el sitio INTRANET - AEROJET SA"
             
."con la siguiente información:\n\n"
             
."Usuario: ".$user."\n."
             
."Contraseña: ".$pass."\n\n."
             
."Si alguna vez pierde u olvida su contraseña, una nueva "
             
."contraseña se generará para usted y sera enviada a "
             
."esta dirección de correo electrónico, "
             
."si desea cambiar su dirección de correo electrónico "
             
."puede hacerlo en la pagina Mi cuenta después de "
             
."iniciar sesión.\n\n."
             
."- Intranet - Aerojet sa.";
             echo 
".EMAIL_FROM_NAME.";
          return 
mail($email,$subject,$body,$from);
   }
   
   
/**
    * sendNewPass - Sends the newly generated password
    * to the user's email address that was specified at
    * sign-up.
    */
   
function sendNewPass($user$email$pass){
      
$from "From: ".EMAIL_FROM_NAME." <".EMAIL_FROM_ADDR.">";
      
$subject "INTRANET - AEROJET SA - Su nueva contraseña.";
      
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
      
$body $user.",\n\n"
             
."Hemos generado una nueva contraseña para usted "
             
."a petición del cliente, puede utilizar esta nueva "
             
."contraseña con su nombre de usuario para iniciar "
             
."sesión en la web INTRANET - AEROJET SA.\n\n."
             
."Username: ".$user."\n"
             
."New Password: ".$pass."\n\n"
             
."Se recomienda que cambie su contraseña para que le "
             
."sea más fácil de recordar, puede hacer esto en la "
             
."página Mi cuenta después de iniciar sesión\n\n.";
             
      return 
mail($email,$subject,$body,$from);
   }
};

/* Initialize mailer object */
$mailer = new Mailer;

?>
Esto es todo si necesitan alguna otra informacion para decirme donde esta el error.

Mi servidor es local, no tengo montado un SMTP, pero si tengo un servidor al cual me conecto mediante smtp y clave para enviar mail.

Saludos.
  #9 (permalink)  
Antiguo 03/03/2011, 09:13
 
Fecha de Ingreso: noviembre-2007
Mensajes: 382
Antigüedad: 16 años, 4 meses
Puntos: 16
Respuesta: Error en Sistema de recuperación de contraseña.

borro lo que he escrito, porque no había visto la clase Mailer.
pruebas a cambiar $mailer = new Mailer; por $mailer = new Mailer(); a ver que pasa? nunca he usado una clase sin constructor :/

Última edición por manzarinaa; 03/03/2011 a las 09:31
  #10 (permalink)  
Antiguo 03/03/2011, 12:57
 
Fecha de Ingreso: julio-2005
Mensajes: 26
Antigüedad: 18 años, 9 meses
Puntos: 0
Pregunta Respuesta: Error en Sistema de recuperación de contraseña.

Estimado(a)s

Y supe cual es el problema, no estaba declarada la clase Mailer en la pagina session.php.

Código PHP:
/**
 * Initialize session object - This must be initialized before
 * the form object because the form uses session variables,
 * which cannot be accessed unless the session has started.
 */
$session = new Session;

/* Initialize form object */
$form = new Form;

/* Initialize mailer object */
$mailer = new Mailer;

?> 

Pero ahora tengo dos problemas.

Código:
Warning: mail() [function.mail]: SMTP server response: 554 Reverse Error, see http://www.xxxxx/nospam/form.cgi?by=reverse&server=IPserver&server_name=xxxxxx.com in \include\mailer.php on line 64

Warning: Cannot modify header information - headers already sent by (output started at \include\mailer.php:64) in \process.php on line 170

Saludos.
  #11 (permalink)  
Antiguo 03/03/2011, 13:23
 
Fecha de Ingreso: noviembre-2007
Mensajes: 382
Antigüedad: 16 años, 4 meses
Puntos: 16
Respuesta: Error en Sistema de recuperación de contraseña.

este es el error que te puse al principio.
Si quieres probarlo en local tienes que tocar el php.ini y alguna cosilla más
  #12 (permalink)  
Antiguo 03/03/2011, 18:08
 
Fecha de Ingreso: julio-2005
Mensajes: 26
Antigüedad: 18 años, 9 meses
Puntos: 0
Respuesta: Error en Sistema de recuperación de contraseña.

Hola manzarinaa

Por favor podrías explicarme cuales son las cosillas que debo tocar en el php.ini para que me funcione el envio de mail desde el localhost.

En espera de su coridal respuesta.

Saludos.

Última edición por arperez; 03/03/2011 a las 18:09 Razón: error con la url

Etiquetas: contraseña, sitemap
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 09:30.