Jump to content

How to code a response from a guess


Pikezer1337

Recommended Posts

So I'm coding a simple program where the goal is to guess the capital of a randomly generated state. I have been able to get the state name to generate and to get the capitals to generate from a drop down menu. However, I'm not sure how to code a response to when a guess is made. For example if the state that is randomly generated is PA and the person selects Harrisburg and clicks Submit I'm not sure how to make it recognize the correct answer and says something along the lines of "That is correct". If you go to the program(linked below) you will see that when a guess is made it will come up with an error and the dropdown box will not populate unless you hit new game.

 

I have attached my code below, if that is not the proper way to share code on these forums I will change it accordingly.

 

If you would like to see the program in question you can go here: http://roadrunner.cs.wcupa.edu/~pp787359/program2/program.php?initial_redirect=1

If prompted for a password it is: foobar   (a randomly generated password)

 

I believe I have all my arrays and if statements are correct but if you see anything odd please let me know. I'm new to coding PHP and happy to learn:)

 

Thank you so much for anyone who reads or answers this!

code.txt

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.