MyBB Community Forums

Full Version: I need help with a script
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello, I am writing a script and I need some help. When I retrieve a form input, do I use the $_POST[] function or does myBB have its own function? Also how do I filter the inputs (numbers and text)? I also need a list of the db functions (for a SELECT with 2 conditions in WHERE, and a 1 line INSERT).

Here's how I executed the SQL queries when i used phpBB:
$sql = 'SELECT user_id, pet_name FROM adoptables_pets WHERE user_id = '. $user->data['user_id'] ." OR pet_name = '". $pet_name ."' LIMIT 1";
$result = $db->sql_query($sql);
$adoption = $db->sql_fetchrow($result);

$sql_ary = array(
	'user_id'		=> $user->data['user_id'],
	'pet_name'		=> $pet_name,
	'pet_type'		=> $pet_type,
	'time'			=> time(),
	'hits'			=> 1,
);
$sql = 'INSERT INTO adoptables_pets '. $db->sql_build_array('INSERT', $sql_ary) .';';
$db->sql_query($sql);
Take a look at $mybb... as in:
$mybb->input[] for the $_POST[] stuff, also $mybb->settings[] and $mybb->user[]

Not sure what other subfields $mybb has offhand,; I've still only delved into a small portion of the Core. MyBB has a LOT of nice shortcuts to just about everything.
You can use the _POST function. I've done it and it works fine. What do you mean filter inputs?

All MyBB db functions are listed at the MyBB Wiki...

http://wiki.mybboard.net/index.php/Database_Methods
(2009-12-08, 02:08 AM)AussieJay Wrote: [ -> ]You can use the _POST function. I've done it and it works fine.

... $_POST is a variable... not a function.