Jump to content

laquerhead

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

laquerhead's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thank you all. Everything's working great!
  2. Thank you kindly! That works perfectly. One question, is the "echo" method you used the preferred/standard way to accomplish this? I don't want to come off as being unappreciative, it just seems like a bit of a hack to me...
  3. Hi, I'm new to PHP and I'm trying to create a simple math game which utilizes an html form to pass on the user's answer to a php script that checks that answer. Here is what I have thus far: game.php: <!-DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-TRansitional.dTD"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>PHP Practice</title> </head> <body> <?php function getRand(){ return rand(1,13); } $lhs=getRand(); $rhs=getRand(); ?> <form action="welcome.php?lhs=$lhs&rhs=$rhs" method="get"> <label value="<?php $lhs;?>" /> <label value="<?php $rhs;?>" /> <input type="text" name="answer" /> <input type="submit" value="Check Answer" /> </form> </body> </html> check.php <?php $lhs = $_GET['lhs']; $rhs = $_GET['rhs']; $correct_answer = $lhs * $rhs; if( $_GET['answer'] == $correct_answer ) echo "Correct!"; else echo "Incorrect. " . $lhs . " X " . $rhs . " = " . $correct_answer; ?> Of course it's not working. I know I'm probably way off and that the value="<?php ... thing won't work like I'm used to in asp pages. Your help/guidance is most apprectiated! Thank You in advance
×
×
  • 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.