MyBB Community Forums

Full Version: More help needed.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Yes, again, it is me, requested help on my Install Hack.

This time, it is a function in which I have never used so you can't blame me. :p

I have this feature, this is actually the main reason why I created the Install Hack in the first place.

It's a function which, when used, sends an update on certain mods to those who have installed that particular mod.

It uses the mail function of PHP, which is a function I have never used before.

I know it requires database information and this is the information that is logged when a user installs the hack.

Username of person who installs
Userid of person who installed
Thread ID of person who installed.

Is this enough to actually make this function work, or is more information needed before even attempting this?

One I'm guessing would be to log the registered emails of the user. Which I'm doing now.
Personally, I would run a query to the database, getting all users that have requested updates for the mod they are viewing, and then send an email to all of them using the mail function.

This code would do it, but obviously you would have to change the values of <table> and <id> to fit your script.

$query = $db->query("SELECT * FROM <table> WHERE id='<id>'");
while($user = $db->fetch_array($query))
{
	mail($user['email'], "Update Notification", $message);
}

Alternatively, you could use the myBB mail function which does more or less the same, but sends it from the same address that your board updates are sent from.

The code would be identical, except that you would write mymail instead of mail.

Eg:

$query = $db->query("SELECT * FROM <table> WHERE id='<id>'");
while($user = $db->fetch_array($query))
{
	mymail($user['email'], "Update Notification", $message);
}
Great! Thanks! Smile