MyBB Community Forums

Full Version: Run a php script/query a database on memeber page
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am trying to add a section on someones member.php page that will query a database and then show the result. But I have no idea how to do this.

This is what I want it to say. The top row that says VIP status is what I need help with. Right now it is blank.
[Image: 20b848aa69.png]


This is what I have atm in my member_profile template.
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
<tr>
<td colspan="2" class="thead"><strong>APP Details</strong></td>
</tr>

<br>

<tr>
<td ><strong>VIP status:</strong></td>
<td >[b]No idea what to do right here[/b]!</td>
</tr>
<tr>
<td ><strong>Ban History:</strong></td>
<td ><a href="http://tf2app.com/sourcebans/index.php?p=banlist&searchText=$steamid_32&Submit=" target=\"_blank\">Search Ban History</FONT></td>
</tr>
<tr>
<td><strong>Comm Block History:</strong></td>
<td ><a href="http://tf2app.com/sourcebans/index.php?p=commslist&searchText=$steamid_32&Submit=" target=\"_blank\">Search Comm History</FONT></td>
</tr>
<tr>
<td ><strong>Hlstats:</strong></td>
<td ><a href="http://tf2app.com/hlstats/hlstats.php?mode=search&q=$steamid_32&st=uniqueid&game=" target=\"_blank\">Search HLstats</FONT></td>
</tr>
</table>




Can anyone help me out? I can make the php page to do the query and only show the result, I just don't now how to make it show up right there.
In the PHP page, just create a variable and then use the variable in the template. For example, in your template, replace
<td >[b]No idea what to do right here[/b]!</td>
with
<td>{$vipstatus}[/td]

Then in your PHP code for that page, before you output_page() just add the variable. Example:
$vipstatus = "test";
eval("\$html = \"".$templates->get("vip_page")."\";"); // replace vip_page with your template name
output_page($html);
(12-10-2015, 05:06 PM)nth Wrote: [ -> ]In the PHP page, just create a variable and then use the variable in the template. For example, in your template, replace
<td >[b]No idea what to do right here[/b]!</td>
with
<td>{$vipstatus}[/td]

Then in your PHP code for that page, before you output_page() just add the variable. Example:
$vipstatus = "test";
eval("\$html = \"".$templates->get("vip_page")."\";"); // replace vip_page with your template name
output_page($html);

That's really it?  I'll give it a try. Do I need an include some where? Or will it auto include it if it is in the root directory of the forum?

Edit: Forgot to ask something that I just remembered now that I started making the script. Any way to get the UID from the page?
Just include global.php and you'll be fine.

To get the uid use $mybb->user['uid']
(12-14-2015, 05:00 AM)nth Wrote: [ -> ]Just include global.php and you'll be fine.

To get the uid use $mybb->user['uid']

That seems to use the id of who ever is logged in. Not the user page you are looking at. I used $vipstatus = "".$mybb->user['uid'] ; to test it, and ever member page said 17, which is my uid. Is there a way to get the uid of the page I am looking at?
Try:
$mybb->get_input('uid', MyBB::INPUT_INT);
I managed to solve it. I used what nth posted to make it show up on the user cp rather then their public profile.
If you still want to use it on their public profile use the get_input() function as I posted previously.