Jump to content

Getting REALLY frustrated making this hangman-type game


KyZu

Recommended Posts

So I started learning PHP a few days ago and I sort of dived right in trying to make things, this was my first program (a simple BMI calculator)

http://pastebin.com/SHfA4pt5

 

Okay but now I wanted to make hangman, and I'm just...so lost, like, I don't even know how to go about it. Here is the code I have so far (some of it commented out because it was just "ideas" I had). Here is what I have so far:

http://pastebin.com/FyQPmR8U

 

So can somebody give me some direction? Is there anything I wrote that is REALLY dumb and unnecessary? Basically I'm trying to find a way to:

- log the guesses (how can I do this if I don't have an array, or nothing to put the values in...do I need to duplicate anything?)

- check to see if a guess has already been made

- replace the underscores with the letter corresponding to that position.

 

and hell I don't even know what else, just trying to get it to work :(

You need to store it using sessions, so the value persists for the duration of the game.

 

session_start(); // MUST be at the top of your script

if(!isset($_SESSION['increment']))
  $_SESSION['increment'] = 1;

echo $_SESSION['increment']++;

 

If you run this script you'll see the value increment every time you refresh the page. The value of 'increment' is persisted between requests.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.