Jump to content

PHP and HTML flow control


vedder

Recommended Posts

Hi guys!

 

First of all I'd like to thank you for reading my question. I think it's a basic one indeed!

 

I've started to learn php and wanted to code a small game in html + php.

The principle is basic:

I generate two random numbers between 1 and 10, $a and $b.

I keep its sum in $result=$a+$b

I echo them to the screen and ask the user to input their sum in an html form input field with a submit button.

When I receive the value from the html form I want to compare if the user input is equal to the sum of the two numbers presented. What happens is that when I hit the submit button the browser reads all the code again and generates two new numbers $a and $b and I cannot compare if what the user inputted is true or not because the browser reads all the file.

 

My question is how can I control the flow of the program to avoid it. Any tips for a  newby like me?  :P

Link to comment
https://forums.phpfreaks.com/topic/255447-php-and-html-flow-control/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.