Jump to content

thejamman

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

thejamman's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Well for what I have when I select a correct letter its not replacing the * with the correct letter. The script knows when I pick any letter out of the word smile it will display s**** thus the script knows s,m,i,l,e is in the word. But if I pick any letter not in smile it will display nothing. So therefore it's not displaying what I want.
  2. I am very new to this language and need a little help on correcting what I have. This is a script for a word guessing game. Allows users to guess the word letter-by-letter by entering a character in a form. Start by assigning a secret word to a variable. After each guess, print the word using asterisks for each remaining letter, but fill in the letters that the user guessed correctly. You need to store the user's guess in a hidden form field. In my example the word is "smile" so if a user guesses "s" the word will look like s**** then if they guess "l" the word will now change to s**l* and so on tell its done. <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://w3.org/TR/xhtml/DTD/xhtml-strict.dtd"> <html> <head> <title>Guessing Game</title> <meta http-equiv="content-type" content="text/html;charset=UTF-8" /> </head> <body> <h1>Guessing Game</h1><hr /> <?php $encryptsecretWord="*****"; $secretWord="smile"; $NumReturn = strpos ($secretWord,$Guess); // returns the number (0-4) of the $guess in the word "smile" $NumWordMatch = substr ($secretWord,$NumReturn,1); // display the corresponding character of the word "smile" $encryptsecretWord=substr_replace($encryptsecretWord,"$NumWordMatch",$NumReturn,1); // puts up stars and works better ***this is the good one*** if (isset($_GET['letter']) && isset($_GET['progress'])) { $Guess = $_GET['letter']; $Hold = $_GET['progress']; if ($Guess == $Hold) echo "<p>You have guessed all letters corectly.</p>"; $check = $secretWord; // test to see if the guess is contained in the secret word if (substr_replace($check,"$NumWordMatch", $Guess,1)!==False) echo "<p>Mystery Word is $encryptsecretWord</p>"; } ?> <form action="untitled2.php" method="get" enctype="application/x-www-form-urlencoded"> <p><input type="hidden" name="progress" size="20" value="<?php if(!empty($_GET['letter'])) echo $_GET['letter'] ?>" /></p> <p><input type="text" name="letter" size="20" value="<?php if(!empty($_GET['letter'])) echo $_GET['letter'] ?>" /></p> <p>Enter a letter and click the Submit Letter button</p> <p><input type="submit" value="Submit Letter" /></p> </form><hr /> </form> </body> </html>
×
×
  • 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.