Sunday, September 9, 2018

Networking - Database Pt. II

After creating your localhost database, with the table containing the user's variables, we can now move on to the next step, putting the database online!

Before we start, you'll need to create an account on 000webhost.com. Their services gives out spaces for your database online, free of charge. And through this blog entry, I will be writing the steps I have taken.

After finishing the php code and finalizing the table, we will need to import our table(s). Concurrently, you'll also have to sign in to your 000webhost site, and create a database there. You will also have to keep track of where you kept your php code (which should be under C > Program Files x86 > XAMPP > htdocs > [PROJECT_NAME]). Underneath 000webhost, there will be a Database tab. From here, you can access their php page, the only difference being that this is the online database, as opposed to your localhost php. You'll also have to access the File Transfer tab, where you'll need to put your php code. And just like that, your game is now online and ready to accept user variables, but, you'll need to do some more code within Unity.

Networking - Database Pt. I

Throughout this trimester, I have been assigned to create the database and the back end coding for our project, Dreadlight. A database or back end essentially means the data storage for all the user ID's, preferences and all. For the Dreadlight project, what we needed were the user's password, email and their username. In this blog, I will be writing about how I managed to tackle this issue.

In order for you to create a database, you will need to download XAMPP. XAMPP allows you to create your own database by using localhost. Imagine localhost as the birth place of your database, it hasn't been published on the internet yet, meaning that no one can use it online. However, you can still use it for testing purposes. Once this step is done, you can create a table. A table keeps the contents in which you want it to keep. A table can be used to keep the properties of objects within the games, such as Item ID's, summary and all, under one big table. For the project, I just created one table, keeping all the user pref's variables (Username, Password and Email). Once your table is complete by filling in the desired fields, you'll have to do some coding with php. There are some tutorials online, especially on YouTube, which can help you out. Link here:
https://www.youtube.com/watch?v=EByl95OMG2o&list=PLTm4FjoXO7ndjPE8JXrJ9MjMfsJv956Qm