PDA

View Full Version : Code Help for Events


Tequila
01-05-2012, 05:46 PM
I'm coding a few events (one is a continuous puzzle collecting event that updates once a month with a new puzzle) and want to have it set up so that once a user "finds" a piece it shows up on a new page (tentatively titled 'puzzle', it would show up as 'puzzle.php?user=$username') that's linked from their profile.

Once a puzzle is completed they should get an message from the system that congratulates them, and hands out a promo code for a limited edition adoptable (only two available per user).

Before I can get it ready I'll need to create the puzzle page that's linked, and a way to see what pieces users have in MySQL to check against my puzzle file (which you can see below).

How would I go about doing this? I'm a little lost on what I need to code.

(PS: My puzzle file which lists all parts of the puzzles)
// ************************************************** ********************************
// Welcome to the puzzle piece randomizer
// This file will generate 15 pieces of puzzles based on the event and season names
// Pieces can be traded in our forums to complete puzzles at any time
// So far our pieces are
// world, dusk, dawn, eclipse, seasons (spring, summer, fall, winter)
// Let's get this finished up then
// ************************************************** ********************************

<?php

$digits = array {
"01.png",
"02.png",
"03.png",
"04.png",
"05.png",
"06.png",
"07.png",
"08.png",
"09.png",
"10.png",
"11.png",
"12.png",
"13.png",
"14.png",
"15.png",
}

$event = array {
"world",
"dusk",
"dawn",
"eclipse",
}

$season = array {
"spring",
"summer",
"fall",
"winter",
}

?>

Hall of Famer
01-06-2012, 01:15 PM
Well to create a subpage in a script file, the easiest way is to define variables such as $page, $act or $more as super global array $_GET['page'], $_GET['act'], or $_GET['more']. This way you can continue to create a PHP form that direct the user to a certain page under certain conditions. The page and url info is stored in the super global $_GET, and thus can be readily extracted to use.

A very good example is account.php, in which the variable $act can have several values, each leading to a different subpage that users can edit their account info. A problem arises if you are creating a game script incase you do not want users to be able to cheat with the 'refresh' and 'back' button. The manipulation of PHP session variables will resolve this issue, but for now its your best interest not to worry about it till later.