Promote User and Notify Them
This tutorial is very easy to follow. First open Notepad++ and type in this.
PHP Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
include("config.php");
if($logged[username] && $logged[userlevel] == 6) {
switch($_GET['promote']) {
default:
echo "<form action='?promote=user' method='post'>
Username: <input type='text' name='user'>
Level: <select name='level'>
<option value='0'>Banned</option>
<option value='1'>Unvalidated user</option>
<option value='2'>Validated User</option>
<option value='4'>Moderator</option>
<option value='6'>Administrator</option>
</select>
<input type='submit' value='Submit'></form>";
break;
case 'user':
$admin = $_POST['user'];
$level = $_POST['level'];
$update = mysql_query("UPDATE `members` SET `userlevel` = '$level' WHERE `username` = '$admin'");
if ($_POST['level'] == 6)
{
//start private message
$to = $admin; //get who it is to
$from = 'Bot'; //who its from
$subject = "Promotion!"; //new subject
$msg = "Hello, $admin! $logged[username] promoted you to an Administrator!"; //the content
$date = date("F j, Y, g:i a"); //the date sent
$do = mysql_query("INSERT INTO `privates` (`to`,`from`,`date`,`subject`,`content`) VALUES ('" . $to . "','" . $from . "','" . $date . "','" . $subject . "','" . $msg . "')") or die(mysql_error()); //insert into the table!
//end private message
}
if ($_POST['level'] == 4)
{
//start private message
$to = $admin; //get who it is to
$from = 'Bot'; //who its from
$subject = "Promotion!"; //new subject
$msg = "Hello, $admin! $logged[username] promoted you to a Moderator!"; //the content
$date = date("F j, Y, g:i a"); //the date sent
$do = mysql_query("INSERT INTO `privates` (`to`,`from`,`date`,`subject`,`content`) VALUES ('" . $to . "','" . $from . "','" . $date . "','" . $subject . "','" . $msg . "')") or die(mysql_error()); //insert into the table!
//end private message
}
echo "$admin is now a $level.";
break;
}
}
?>
Viola. Then press CTRL+S to save it as... promote.php
Then add to your site. That easy! Also the user will be notified by PM if they have been promoted (to mod or admin).