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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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