'Guess a number' - pervert version (with hidden fields and arrays)

Hello! I’m rookie.

Please help me to solve problem with storing stuff in hidded fields for ‘Guess a number’ program:

https://hastebin.com/vomasuvere.xml

Why this…
[php]if ($choice == ‘big’){
print $guess[1]=($guess[0] / 2);
} elseif ($choice == ‘small’) {
print $guess[2]=($guess[0] + 25); [/php]
…doesn’t work?

p.s.
I know that it’s the worst decision to use arrays and hidden fields in such program; but I’ve made decision to make it like this and can’t drop it :slight_smile: Please help!

p.p.s.
This is my live stream, how I made this program - https://www.youtube.com/watch?v=lLQ4J2JkO60

I though I had all errors on, but it seems NOTICE was off. With this:
error_reporting(E_ALL);
ini_set(‘display_errors’, ‘1’);
I saw notices:

Notice: Undefined index: $guess in C:\OpenServer\domains\localhost\php\17.php on line 6 Notice: Undefined index: $choice in C:\OpenServer\domains\localhost\php\17.php on line 7 Is your number 50?

So I understand that got troubles with forms.

And after I worked some time, I noticed that I got silly error:
$guess = $_POST[’$guess’];
It has to be:
$guess = $_POST[‘guess’];

So, what I got now, it works as intended:
https://hastebin.com/dedoqixahu.http

Good luck!

Sponsor our Newsletter | Privacy Policy | Terms of Service