Jump to content

Simple PHP Adoptable Script - Need Help


Ravenswing

Recommended Posts

Hi! I'm Raven.

 

Obviously you read the title and clicked to see what I need help with. So right off the bat I am thanking you. I'm relatively new to coding. Although I can say I'm pretty good with HTML and CSS. PHP on the other hand is proving to be somewhat difficult. After I write the script I plan to share it so that other's may have something to start their own site if they wish. If you don't want to hear the story then feel free to skip the next paragraph to the part where I actually explain what I need to know.

 

A few of my friend and I want to create a simple adoptable pet website. Not really for anyone else just for us to have fun with and start learning about being webmasters and programming. I got stuck with the programming part. Not that I mind I volunteered it seemed fun, and it is when I know what I'm doing.

 

I am using phpBB forum script. Which to insert my script into I need to separate the PHP and HTML into two different files for each page. I also am using a SQL database and a table that will store the pet information. Although I don't know much about SQL I'll be looking at the W3Schools tutorials for it.

 

Now the PHP is where I run into trouble. I've looked at several adoptable scripts to get an idea of how they work. I want to write this on my own and not use a pre-made script. The script will be pretty basic. Simply you adopt a pet, it goes to the users "my pets" and then grows by its self through 2-3 different stages. I'd like it if when you clicked on the pet to view it you would get a BBcode for the pet you could use to display it in the forum. And possibly a way to trade pets. However trading can wait, until I can get the adopt part done.

 

I've tried writing the script multiple times but I never get far. I feel like I'm doing it completely wrong and I really would like some help figuring it out.

 

This is the PHP Half of the Adoption Page

 <?phpdefine('IN_PHPBB', true);$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';$phpEx = substr(strrchr(__FILE__, '.'), 1);include($phpbb_root_path . 'common.' . $phpEx);// Start session management$user->session_begin();$auth->acl($user->data);$user->setup();page_header('adoptionpage');$template->set_filenames(array(    'body' => 'adoptionpage.html',));make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"));page_footer();?>

Here is the HTML half of the Adoption Page

 <!-- INCLUDE overall_header.html --><h2>Adoption Center</h2><div class="panel">   <div class="inner"><span class="corners-top"><span></span></span>   <div class="content">      <p>  Welcome to the adoption center! Here you will find all sorts of unique creatures!  Check out what we have for adoption this month!  </p>   <p>   <table width="400" border="0" cellspacing="0" cellpadding="4">  <tr>    <td><img src="krintpup11.png"></td>    <td>     <form action='adopt.php' method='post'>         <input type="hidden" name="id" value="1">                  <input type="submit" value="Adopt me!">        </form>    </td>  </tr>  <tr>    <td><img src="krintpup12.png"></td>    <td>     <form action='adopt.php' method='post'>         <input type="hidden" name="id" value="2">                                <input type="submit" value="Adopt me!">        </form>       </td>  </tr></table>   </p>   </div>   <span class="corners-bottom"><span></span></span></div></div><!-- INCLUDE jumpbox.html --><!-- INCLUDE overall_footer.html -->

As you can see I have no idea what I'm doing. Can someone point me in the right direction? I've already looked through the PHP tutorials on W3Schools. Multiple times. However I am determined to figure this out and make it work.

Link to comment
Share on other sites

This is going to be pretty complicated for somebody who isn't experienced in programming. HTML and CSS are languages that describe and present data, but are not actual programming languages. Programming languages are quite a bit more complicated to learn.

 

For your project you first need to decide what data your system has and what data structures you're going to use for it.

 

One thing your system will have is probably a pet, or adoptable. Your pet will probably be an object with properties, such as "name", "species", "level", "image". It's up to you to determine all the properties your pet is going to have.

 

To work with data that's just properties and values in PHP I recommend an associative array:

$pet = array();$pet['name'] = 'Sparky';$pet['species'] = 'Dog';$pet['level'] = 1;$pet['image'] = 'dog.jpg';

You'll have to have scripts that create these objects, store them in the database, retrieve them from the database and display them on the page.

 

You probably will need more kinds of objects, like maybe a species object that has properties common to all the pets of a particular species. This is where, in the database, you would have a relation between two different types of data, "pet" and "species". You'll have to learn database theory.

 

Integrating this with PHPBB is probably going to be more difficult as a learning process than doing it without forum software. Once you actually know PHP you can try integrating this into the forum. You're trying to take on too much.

Link to comment
Share on other sites

Thanks for the tips! I know I'm taking on a lot but I'm determined to figure it out. Hopefully quickly. But if I need to slow down to figure everything out I will. I'm not on a deadline although, my buddies want the site as soon as possible. I said it could take anywhere between three to eight months. Is that reasonable?

 

I took a class in JS and while im not an expert I have a good understanding of JS. I was told to learn JS before attempting to learn PHP and that PHP wouldn't be too hard to learn.

 

I wont be using leveling. I want it to be based on how old the adopt is. I've been looking at the PHP time/date functions and I can't figure out which one I need, I've been using an .xml file. Should I stick with that?

 

Here is the file I currently have:

<adoptables> <adoptable id="1">     <variation id="1" chance="1.0">        <age image="krintpup11.png" />        <age date="2014-09-12" image="krintpup11.png" />        <age date="2014-09-13" image="krintteen11.png" />    </variation>    <variation id="2" chance="5.0">         <age image="krintpup12.png" />        <age date="2014-09-12" image="krintpup12.png" />         <age date="2014-09-13" image="krintadult12.png" />     </variation> </adoptable><adoptable id="2">    <variation id="1" chance="1.0">         <age image="dragonbaby2.png" />        <age date="2014-09-23" image="dragonadult2.png" />    </variation></adoptable></adoptables>

My only concern is if I'll have to change the .xml file every time I want to change the pets. (Which isn't a big deal)

 

I actually managed to get the adoption page working on phpBB. You could click adopt and then it would say thank you for adopting this pet. But that's where it stopped. I didn't have anywhere for the pet to go. I would need to send it to the users "My Pets" Which I haven't figured out how to code yet.

 

This'll be a tough process im sure but I hope people will be kind and patient enough to help me.

Edited by Ravenswing
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...