Jump to content

scifiguy

Members
  • Posts

    11
  • Joined

  • Last visited

scifiguy's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. You are right or wrong still did not echo.
  2. I got this error when I changed the function: Fatal error: Can't use function return value in write context in /var/www/index.php on line 42
  3. Nothing happens. It auto corrects to the right answer.
  4. The goal of this part is to test if the user is right if they enter something in the results box. If the user is right, The program will output you are right, otherwise, It will output you are wrong. This is how I thought to do it, but it doesn't work: if ($_POST['a3']==$a3){ echo"You are right."; } { else echo"You are wrong."; }
  5. Does anybody know how to see if an inputted value on a form matches a variable?
  6. Nervermind. I got it to work. How can I use this to change the text depending on weather the number are added, subtracted, multipled, or divided?
  7. It says unexpected {. I copied the function into a new php section.
  8. I need to have a statement when the page loads that says waiting for input. My instinct was to use the GET method. If so, how do I do that?
  9. How can I use GET to echo out text? $_Get[status]; $status=Waiting for user input. echo $status;
  10. Thank you for your help with the addition method. I tried to duplicate what you did for the other methods, but all that outputs is the sum for Addition. I tried to change the if statements to else if structure, but it doesn't compile it just says unexpected else. Any ideas? I also need to finish changing the text based on operation. Thanks again.
  11. Hello fellow coders I am having an issue coding a php calculator. My objective is to make it so that text changes depending on the operation chosen, and the answer is in the text box. if you dont input an answer, it will give you the right answer. here is how the website is supposed to act:http://usefullittlethings.com/static/index_done.php here is my code: <!DOCTYPE html> <html> <head> <title>Online Math Calculator</title> </head> <body> <h1>Thank you for trying out the online math calculator.</h1> <h2>Enter two numbers to add, subtract, multiply, or divide.</h2> <h3>If you enter the result, I will tell you if what you entered is right.</h3> If you don't enter both numbers for a formula, I will ignore it.<br /><br /> <?php $status= 'Waiting for input.<br>'; echo $status; ?> <?php function Calc(){ if (isset($a1)&&!isset($a2){ if (!empty($a1)&&!empty($a2) $a3=$a1+$a2; echo $status.'two numbers added.' } } ?> <form action="index.php" method="post"> <strong>Addition:</strong><br /> <input type="text" name="a1" value="" /> plus <input type="text" name="a2" value="" /> equals <input type="text" name="a3" value="" /> <br /><br /> <strong>Subtraction:</strong><br /> <input type="text" name="s1" value="" /> minus <input type="text" name="s2" value="" /> equals <input type="text" name="s3" value="" /> <br /><br /> <strong>Multiplication:</strong><br /> <input type="text" name="m1" value="" /> times <input type="text" name="m2" value="" /> equals <input type="text" name="m3" value="" /> <br /><br /> <strong>Division:</strong><br /> <input type="text" name="d1" value="" /> divided by <input type="text" name="d2" value="" /> equals <input type="text" name="d3" value="" /> <br /><br /> <input type="submit" value="Calculate!" /> </form> </body> </html> Thanks. Any help is appreciated!!!!!!!!!!!!!!!!!
×
×
  • 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.