Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Call to undefined method forgotpass::generatePassword()
Old 01-19-2010, 02:33 AM Call to undefined method forgotpass::generatePassword()
Isabella_Smith's Avatar
Ultra Talker

Posts: 285
Trades: 0
Hi,

I am having problem with running generatingPassword ()

please let me know if this is wrong method of defining.....and plz tell me the correct way....

Erro: Call to undefined method forgotpass::generatePassword()

Coding: $newpass = $this->generatePassword(6);

Thanks in advance for your help.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE



Please login or register to view this content. Registration is FREE
buy all indian salwar Kameez, Sarees and clothes
Isabella_Smith is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-19-2010, 02:43 AM Re: Call to undefined method forgotpass::generatePassword()
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
The error message means that the generatePassword() method does not exist in the forgotpass class. The syntax of the code you posted is correct, but the method does not exist.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 01-19-2010, 04:19 AM Re: Call to undefined method forgotpass::generatePassword()
Isabella_Smith's Avatar
Ultra Talker

Posts: 285
Trades: 0
Quote:
Originally Posted by NullPointer View Post
The error message means that the generatePassword() method does not exist in the forgotpass class. The syntax of the code you posted is correct, but the method does not exist.
Thanks NullPointer,

Please let me know if this is correct method:

function generatePassword ($length = 8)
{


$password = "";


$possible = "0123456789bcdfghjkmnpqrstvwxyz";


$i = 0;


while ($i < $length) {


$char = substr($possible, mt_rand(0, strlen($possible)-1), 1);


if (!strstr($password, $char)) {
$password .= $char;
$i++;
}

}


return $password;

}
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE



Please login or register to view this content. Registration is FREE
buy all indian salwar Kameez, Sarees and clothes
Isabella_Smith is offline
Reply With Quote
View Public Profile
 
Old 01-19-2010, 04:41 AM Re: Call to undefined method forgotpass::generatePassword()
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
You cannot refer to object through $this outside the class. You should first create instance of a class and then call its method:

$generator = new forgotpass();
$password = $generator->generatePassword();
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 01-19-2010, 05:03 AM Re: Call to undefined method forgotpass::generatePassword()
Isabella_Smith's Avatar
Ultra Talker

Posts: 285
Trades: 0
Hi mtishetsky,

$this is defined under the class forgotpass, its not out.

Here's the full coading.....please let me know where is the mistake.

thanks

PHP Code:
<?php
class forgotpass extends functions
{
    function 
forgotpass($post)   //For forgot password.
    
{    
        
$newpass $this->generatePassword(8);
        
        
$sql_select "select * from tbladmin where admin_name = '".$post['username']."'";
        
$result_select mysql_query($sql_select);
        
$numrows mysql_num_rows($result_select);
        
        if(
$numrows){
            
$sql_edit "update tbladmin set `admin_pass`='".($newpass)."' where admin_name = '".$post['username']."'";
            
$result_edit  mysql_query($sql_edit);
            
$this->forgotpass_mail($post['username'],$newpass);
            
$_SESSION["msg"] = "Password reset successfully. Please check your mail for new login details.";
        }
        else
            
$_SESSION["msg"] = "Invalid ! username. Please enter the correct one.";
        return 
true;
    }
    
    function 
forgotpass_mail($username,$pass)  // send the userid and passsword to the admin.
    
{
        
$fromname "DialIndiaDial - Support";
        
$fromemail "danish@dialindiadial.com";
        
$toname "DialIndiaDial - Admin";
        
$toemail "danish@dialindiadial.com";
        
//$bcc = "danish@magicsolv.com";
        //$bcc = "";
        
$subject "DialIndiaDial - Forgot Password Request";
        
        
$message "Dear Administrator,<br><br>
        
    Your password has been reset successfully. Here are your new login details:<br><br>
    
Username : "
.$username."<br>
Password : "
.$pass."

<br><br>
Regards,<br>
DialIndiaDial - Support
"
;
        
$this->send_mail($fromname$fromemail$toname$toemail,$bcc$subject$message);
    }
}

function 
generatePassword ($length 8)
{

  
  
$password "";

  
  
$possible "0123456789bcdfghjkmnpqrstvwxyz"
    
  
  
$i 0
    
  
  while (
$i $length) { 

    
    
$char substr($possiblemt_rand(0strlen($possible)-1), 1);
        
    
    if (!
strstr($password$char)) { 
      
$password .= $char;
      
$i++;
    }

  }

  
  return 
$password;

}
?>
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE



Please login or register to view this content. Registration is FREE
buy all indian salwar Kameez, Sarees and clothes
Isabella_Smith is offline
Reply With Quote
View Public Profile
 
Old 01-19-2010, 06:38 AM Re: Call to undefined method forgotpass::generatePassword()
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
As far as I see, you have generatePassword function declared outside of the class, so it is not the class method. No wonder that you get "undefined method" error.
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Reply     « Reply to Call to undefined method forgotpass::generatePassword()
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.33555 seconds with 12 queries