I made a script which my site's users can use to change their forum rank to custom of their choice (they're able to type own rank text and upload own image) at the cost of very small amount of money.
The problem is that when the rank is changed, it isn't visible in the forum, but everything seems alright - image is uploaded to the right folder, user_rank field updated in the phpbb_users table with the rank_id from the newest entry at phpbb_ranks table.
I'm posting a lite version of the script I made:
Code: Select all
<?
//mysql connection already made
$new_rank_text = htmlspecialchars(trim(iconv("windows-1251", "utf-8", $_POST['new_rank_text'])));
$user_id = $user->data['user_id'];
//then I upload the image file to forum/images/ranks/
$rank_image="new_rank.gif";
mysql_query("INSERT INTO phpbb_ranks
(rank_title, rank_min, rank_special, rank_image) VALUES('$new_rank_text', '0', '1', '$rank_image')")
or die(mysql_error());
$result = mysql_query("SELECT rank_id FROM phpbb_ranks ORDER BY rank_id DESC LIMIT 1") or die(mysql_error());
$row = mysql_fetch_array( $result );
$new_rank_id = $row['rank_id'];
$result = mysql_query("UPDATE phpbb_users SET user_rank='$new_rank_id' WHERE user_id='$user_id'")
or die(mysql_error());
?>
Code: Select all
$user_rank = $user->data['user_rank'];
$result = mysql_query("SELECT rank_title, rank_image FROM phpbb_ranks WHERE rank_id='$user_rank'") or die(mysql_error());
$row = mysql_fetch_array( $result );
echo iconv("utf-8", "windows-1251", $row['rank_title']).'<br />'; if(!empty($row['rank_image'])){echo '<img src="http://cs-bg.info/forum/images/ranks/'.$row['rank_image'].'" alt="rank image" />';
Thanks in advance.