Forgot Password / Register
Site Statistics
Total Members: 520
Total Tutorials: 242
Newsest User: 8884244477
Todays Unique Hits: 381
0 Users 14 Guests Online

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).
UrbanTwitch
Views:
2139
Rating:
Posted on Wednesday 23rd July 2008 at 08:07 PM
UrbanTwitch
UrbanTwitch
Because the $_POST['user']; is where you promote the user so $_POST['user']; is same as $admin which goes to $to so it knows who to send it to!
Posted on Wednesday 23rd July 2008 at 07:03 PM
Diablosblizz
Diablosblizz
What's the point of $to, as it's the SAME thing as $admin.
Posted on Wednesday 23rd July 2008 at 05:22 PM
UrbanTwitch
UrbanTwitch
Snippits?
Posted on Wednesday 23rd July 2008 at 03:39 PM
ilyas-shezad
ilyas-shezad
Not bad not bad... Daniel you need snippets section for next RMB version :p
Posted on Wednesday 23rd July 2008 at 02:59 PM
UrbanTwitch
UrbanTwitch
At first I tested it out as Administrator. I forgot to change.
Posted on Wednesday 23rd July 2008 at 02:12 PM
MrArmstrong
MrArmstrong
ok cool i like it :P
Posted on Wednesday 23rd July 2008 at 07:38 AM
darklight19
darklight19
$msg = "Hello, $admin! $logged[username] promoted you to a Moderator!"; //the content

What's with $admin?