MyBB Community Forums

Full Version: php script help :)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4
How can i get a php script to display something depending on the uid entered in the url bar?

For example i have this:
$query = $db->simple_select('users', 'username,usergroupid,posts', 'uid=\''.intval($mybb->input['userid']).'\'');
$user = $db->fetch_array($query); 
 

in my script, but i want it so i can use it for vbulletin and other softwares too.

currently i type in the url bar:
www.mysite.com/myscript.php?uid=1 and that grabs the info for the user id in the url bar. I want to take out the mybb bit Smile


ALSO: Is there any way i can get whatever i type in the url into an image?

EG: www.mysite.com/myscript.php?text=your_text_here

Prints "your_text_here" on an image.

so; $text=.....
the 'mybb bit' is what the script puts into the query, so you can use whatever your variable source is, either fixed value or from a variable you initialize in your script.

if you want to grab what is passed via the URl then you need to use $_POST and $_GET (better coding to use those than assume registar_globals is enabled, its bad coding anyway) and test if the 'uid' variable is set and validate that variable and then put it into the query.

As for the iamge output, you need gd or imagemagick and create the image on the fly.
ok, could somebody help me with how i would structure this for the query?
(2009-09-28, 08:54 PM)pavemen Wrote: [ -> ]if you want to grab what is passed via the URl then you need to use $_POST and $_GET (better coding to use those than assume registar_globals is enabled, its bad coding anyway) and test if the 'uid' variable is set and validate that variable and then put it into the query.

No, not necessarily. You can use $mybb->input instead of $_POST and $_GET. For example, if a URL is myforum.yoo/member.php?action=profile&uid=1&do=getlastposts, you can do the following:

echo $mybb->input['action']; // will echo "profile"
echo $mybb->input['uid']; // will echo "1"
echo $mybb->input['do']; // will echo "getlastposts"

So in your example, you will need use the $mybb->input['uid'].

Smile
What I've always wondered is how does $mybb->input know if it's post or get data, does it just check for both??
Basically, it doesn't know. When the script is loaded, it loads all $_GET and all $_POST variables into the $mybb->input array.

You can check if something is being posted by the request method:

if($mybb->request_method == "post")
{
     // Being posted
}
elseif($mybb->request_method == "get")
{
     // Normal...
}
(2009-09-29, 07:52 AM)Tomm M Wrote: [ -> ]So in your example, you will need use the $mybb->input['uid'].

Ok, thanks.

I think this is probably the wrong place to ask but does anyone know how to do this for vbulletin?


Also what is the name of the file in mybb that creates these commands.
You will need to ask the vBulletin team on their forums.

$_GET and $_POST => $mybb->input is found in ./inc/class_core.php.
I mean not specifically for vbulletin, but for anything where it simply gets the info from the database. When i type "?uid=" at the end it searches the database for the info Smile
You can use $_GET['uid'] in normal circumstances.
Pages: 1 2 3 4