MyBB Community Forums

Full Version: fid, pid, tip, etc.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I'm working on a project for one of my friends where I want it to be like MyBB in the concept of having each page have its own id. So, I want it to be like url/page.php?pageid=1 and for each page, a different pageid. These can be stored in a MySQL database, and I do have one ready. Could someone just like explain very easily how I can be able to do that? Let me know if you need more information.
you would need to make the pages id the key field in the database (auto increment) and then you can use the $_GET function in PHP to get the page id from the URL and then search for the database for the id which matches the one being asked for and then return the rest of the data that the id corresponds to (stuff like the actual content).
Make sure to sanitize your $_GET input with intval() or mysql_real_escape_string() before processing it in MySQL
Um..I really don't get what any of that means. I know that $_GET is used to get information from a form/url, but that's it. Could you guys explain it a bit more?
Okey so "not sanatizing" means there's a possibility you can get hacked

To "sanatize" something do like the following:

// ONLY USE THIS FOR NUMBERS!
$somenumber = intval($_GET['someinput']);

// Use this for MySQL Queries to stop "SQL Injections"
$somestring = mysql_real_escape_string($_GET['someinput2']);

Hope that helps,
Cheers,
Tikitiki
But how would that 'someinput' differ per topic made? Like so it changes for tid=1 then a new topic would be tid=2 and so on and so forth
It's because you can also make tid=some%20text%20here which could be code to exploit your database.

It's best to be safe than sorry Smile
What I'm asking (asking in post 6 that is) is how, when you make a new thread on a forum (EXAMPLE!), it nows what tid is one higher than the most recent one. Could you explain that and make sure it's really clear? And what's a mysql_real_escape_string?
mysql_real_escape_string makes sure that no sql exploits can be performed on that input.

When creating a table to make it automatically increment you have to use this: auto_increment
You lost me at sql exploits. This is really starting to confuse me. All I really know is the basics of PHP and MySQL queries built into PHP. Like how would you make it so that when a person makes the first topic ever, it is marked as tid=1 and stored into the row in the MySQL database as tid1 and it's value is the content in the post? From there all other topics made are the same, but their tid goes up one for every new topic. How's that done?
Pages: 1 2