CANNOT GET THIS PHP CODE RIGHT HELP!!!! PLEASE!!!!?

Ivan

New member
I am doing homework and I cannot figure out what i'm doing wrong, can someone please please help me since the teacher is no help.

This is "i'm thinking of a number game".

<html>
<head>
<title>I'm Thinking of A Number!</title>
<style type = "text/css">
body {
background: green;
color: yellow;
}
</style>
</head>
<body>
<?php
if ($guessNum == FALSE){
$guessNum = 1;
initial();
}
while ($guess != $random){

print "You guessed $guess<br>";
if($guess = $random){
print "That is correct!<br>";
print "It took you $guessNum tries";
}else{if($guess < $random){
print "That's too low";
second($guess);
}
}
if($guess > $random){
print "That's too high";
second($guess);
}

}

function second(){
$guessNum++;
print <<<HERE
<input type = "text"
name = "guess"
value = $guess>

<input type = "hidden"
name = "hiddenGuess"
value = $random>

<input type = "submit"
value = Enter>
HERE;
}

function initial(){
global $random, $guess;
$random = rand(1, 100);
print <<<HERE
<h2>Please guess a number between 1 and 100</h2><br><br>
<input type = "text"
name = "guess"
value = $guess>

<input type = "hidden"
name = "hiddenGuess"
value = $random>

<input type = "submit"
value = Enter>
HERE;
}

?>
</body>
</html>
 
Back
Top