Pikezer1337 Posted February 26, 2016 Share Posted February 26, 2016 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 Quote Link to comment https://forums.phpfreaks.com/topic/300899-how-to-code-a-response-from-a-guess/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.