webdevdea Posted March 14, 2014 Share Posted March 14, 2014 I have my code almost working, I am still new with this so if someone could help me understand why this thing is letting you know you win if you choose anything between 20 and 25? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html lang="EN" dir="ltr" xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Computer can you guess my number</title> <style type = "text/css"> #footer {font-size:xx-small; text-align:center; clear:right; padding-bottom:20px; } body { background-image:url("img_tree.png"); color: RED;text-align:center } p { color: Blue; text-align:center;} </style> </head> <body> <?php $guess=$_POST['guess']; $number= 25; if($guess>$number) { echo "Sorry, your guess is too high, try again"; echo "<form method=\"post\" name=\"guess\"> <input type=\"hidden\" name=\"number\" value=\"$number\"> Pick a number 1 through 25: <input name=\"guess\" type=\"text\"> <input name=\"submit\" type=\"submit\" value=\"Submit Guess\"> </form>"; }elseif($guess <15){ echo "Sorry, your guess is too low, try again"; echo "<form method=\"post\" name=\"guess\"> <input type=\"hidden\" name=\"number\" value=\"$number\"> Pick a number 1 through 25: <input name=\"guess\" type=\"text\"> <input name=\"submit\" type=\"submit\" value=\"Submit Guess\"> </form>"; }elseif($guess = $number) { echo "You got it, good guess"; echo "You got it, good guess."; $number= 25; echo "<form method=\"post\" name=\"guess\"> <input type=\"hidden\" name=\"number\" value=\"$number\"> Pick a number 1 through 25: <input name=\"guess\" type=\"text\"> <input name=\"submit\" type=\"submit\" value=\"Submit Guess\"> </form>"; } else{ ?><form method="post" name="guess"> <input type="hidden" name="number" value="<?php echo $number; ?>"> Pick a number 1 through 25: <input name="guess" type="text"> <input name="submit" type="submit" value="Submit Guess"> </form> <?php } ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
Solution requinix Posted March 14, 2014 Solution Share Posted March 14, 2014 (edited) }elseif($guess = $number) {One equals sign is for assignment, two equals signs are for comparison. Edited March 14, 2014 by requinix Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.