Jump to content

[SOLVED] Acessing functions


kwdrysdale

Recommended Posts

Ok...I am so close to getting what I want I can almost taste it! :)  First, I'll explain.  I am working with an open source membership script.  I have modified it to work with userlevels so that we have to manually approve each user that registers.  When they register, it sends them an email telling them they successfully registered, but are not approved yet.  When I approve them (from admin center) I was hoping to be able to have the 'approved' email sent automatically.  Here is some snippets of what I have:

 

form code from admin center to change userlevel:

<table>
<form action="adminprocess.php" method="POST">
<tr><td>
Username:<br>
<input type="text" name="upduser" maxlength="30" value="<? echo $form->value("upduser"); ?>">
</td>
<td>Level:<br><select name="updlevel"><option value="1">1<option value="2">2<option value="9">9</select></td>
<td>
<br>
<input type="hidden" name="subupdlevel" value="1">
<input type="submit" value="Update Level">
</td></tr>
</form>
</table>

 

The code to update the userlevel (from adminprocess.php) in the database and HOPEFULLY send the email.  All code before this was error checking to ensure the username entered matches a username in the database:

$database->updateUserField($subuser, "userlevel", (int)$_POST['updlevel']);
         if($_POST['updlevel'] >= 2){
            $uduinfo = $database->getUserInfo($_POST['upduser']);
            $udemail = $uduinfo['email'];
            $uduser = $uduinfo['fname'];
            $mailer->sendApproved($uduser,$udemail);
         }

 

The getUserInfo code from database.php:

function getUserInfo($username){
      $q = "SELECT * FROM ".TBL_USERS." WHERE username = '$username'";
      $result = mysql_query($q, $this->connection);
      /* Error occurred, return given name by default */
      if(!$result || (mysql_numrows($result) < 1)){
         return NULL;
      }
      /* Return result array */
      $dbarray = mysql_fetch_array($result);
      return $dbarray;
   }

When I try to make the userlevel 2 or greater, I get this error:

Fatal error: Call to a member function sendApproved() on a non-object

and this is the offending line:

$mailer->sendApproved($uduser,$udemail);

 

Any suggestions on what should be changed to fix this problem?  I am really new to PHP (like I think I say in every post) so I am hoping I posted enough of the code, and that it is a simple problem.  Thanks for any help.

 

Kevin

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.