runnerjp Posted May 21, 2007 Author Share Posted May 21, 2007 any 1 able to help n0ob in right direction please Quote Link to comment Share on other sites More sharing options...
JakeTheSnake3.0 Posted May 21, 2007 Share Posted May 21, 2007 <?php class Mailer { function Mailer() { // Class constructor } /* * 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 = "runnerselite - registration"; $body = $user.",\n\n" ."We've generated a new password for you at your " ."request, you can use this new password with your " ."username to log in to runnerselite.\n\n" ."Username: ".$user."\n" ."New Password: ".$pass."\n\n"; $key = randomkeys(16); $body .= "http://runnerselite.com/login/activate.php?id=". $key ."\n\n"; 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 = "Jpmaster77's Site - Your new password"; $body = $user.",\n\n" ."We've generated a new password for you at your " ."request, you can use this new password with your " ."username to log in to Jpmaster77's Site.\n\n" ."Username: ".$user."\n" ."New Password: ".$pass."\n\n" ."It is recommended that you change your password " ."to something that is easier to remember, which " ."can be done by going to the My Account page " ."after signing in.\n\n" ."- Jpmaster77's Site"; return mail($email,$subject,$body,$from); } } /* Initialize mailer object */ $mailer = new Mailer; ?> You had both functions in your class called the same thing. Quote Link to comment Share on other sites More sharing options...
MadTechie Posted May 21, 2007 Share Posted May 21, 2007 Cannot redeclare sendnewpass() because you have that function twice... Quote Link to comment Share on other sites More sharing options...
runnerjp Posted May 22, 2007 Author Share Posted May 22, 2007 yes i found that 1 out im gtting Fatal error: Call to a member function on a non-object in /home/runnerse/public_html/website/login/include/mailer.php on line 5 <?php class Mailer { function sendWelcome($user, $email, $pass){ $key = $database->randomkeys(16); $from = "From: ".EMAIL_FROM_NAME." <".EMAIL_FROM_ADDR.">"; $subject = "runnerselite - registration"; $body = $user.",\n\n" ."We've generated a new password for you at your " ."request, you can use this new password with your " ."username to log in to runnerselite.\n\n" ."Username: ".$user."\n" ."New Password: ".$pass."\n\n"; $body .= "http://runnerselite.com/login/activate.php?id=". $key ."\n\n"; return mail($email,$subject,$body,$from); } } /* Initialize mailer object */ $mailer = new Mailer; ?> Quote Link to comment Share on other sites More sharing options...
runnerjp Posted May 22, 2007 Author Share Posted May 22, 2007 i think what i need to do is calculate $key before the function call, and pass in that, but how would i do this :S Quote Link to comment Share on other sites More sharing options...
runnerjp Posted May 22, 2007 Author Share Posted May 22, 2007 <?php class Mailer { global $database; $key = $database->randomkeys(16); function sendWelcome($user, $email, $pass){ $from = "From: ".EMAIL_FROM_NAME." <".EMAIL_FROM_ADDR.">"; $subject = "runnerselite - registration"; $body = $user.",\n\n" ."We've generated a new password for you at your " ."request, you can use this new password with your " ."username to log in to runnerselite.\n\n" ."Username: ".$user."\n" ."New Password: ".$pass."\n\n"; $body .= "http://runnerselite.com/login/activate.php?id=". $key ."\n\n"; return mail($email,$subject,$body,$from); } } /* Initialize mailer object */ $mailer = new Mailer; I GOT THE ERROR Parse error: syntax error, unexpected T_GLOBAL, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/runnerse/public_html/website/login/include/mailer.php on line 4 Quote Link to comment Share on other sites More sharing options...
JakeTheSnake3.0 Posted May 22, 2007 Share Posted May 22, 2007 Do more research in regards to php classes and the all-important concept of 'scope'. The reason why your function isn't working is because in the scope of the class, it hasn't been declared yet. You should consider a class to be completely separate from any other script, no matter where the class resides. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.