2009-06-17, 08:38 PM
Hi, I'm learning PHP, and I am trying to make a simple number script. I have made one, but it Does not detect the right answer if it is right, it tells you it's wrong.
These are the 2 files.
test.html:
<html>
<head>
<title>Test</title>
</head>
<body>
<div align="center">Please guess a number! <br/>
</div>
<form action="test2.php" method="POST" name="guess" id="guess">
<div align="center">
<p>
<input name="guess1" type="text" id="guess1" size="2" maxlength="2">
<input name="guesssub" type="submit" id="guesssub" value="Guess!">
</p>
</div>
</form>
</body>
</html>
test2.php:
<?php
$number = array( "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" );
shuffle($number);
if ( $number == $_POST[".guess"] ) {
echo "Great Job! Your number was: $number";
} else {
echo "Please try again. The number was: $number[0]";
}
?>
any Ideas?
These are the 2 files.
test.html:
<html>
<head>
<title>Test</title>
</head>
<body>
<div align="center">Please guess a number! <br/>
</div>
<form action="test2.php" method="POST" name="guess" id="guess">
<div align="center">
<p>
<input name="guess1" type="text" id="guess1" size="2" maxlength="2">
<input name="guesssub" type="submit" id="guesssub" value="Guess!">
</p>
</div>
</form>
</body>
</html>
test2.php:
<?php
$number = array( "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" );
shuffle($number);
if ( $number == $_POST[".guess"] ) {
echo "Great Job! Your number was: $number";
} else {
echo "Please try again. The number was: $number[0]";
}
?>
any Ideas?