I made a BlackJack game using only php, and html of course for the layout. But what im trying to say is I need to only use PHP. So no javascript or something else.
My game is near completion, all that's left is the buttons.
I have 3 buttons, Start, Hit and the Stand button. These buttons work with forms, If you click Start it will submit a form where the player draws 2 cards and the dealer 1. Then if you click hit it submits a form where the page will give you 1 card. And by clicking Stand it lets the dealer play, drawing cards untill he hits => 17.
I hope you understand how my system works. (If not please tell me!)
Now when i start the program all buttons except Start needs to be disabled, when i submit the start form (Click the start button) it needs to disable the start button and enable all the others. I find this complicated to achieve since I've never done anything like this before without javascript.
I tried the following:
if (!isset($_SESSION["buttons"])){$_SESSION["buttons"]='disabled';}
This runs at the very start of the form, and in the buttons i echo the session out, so when i start it for the first time it disables all buttons, this works fine.
But when i click start, and run this:
if(FORM_start("Start")){
buttons();
}
And buttons(); being the following:
function buttons() {
$_SESSION["buttons"] = '';
}
It doesn't work the first time i click on Start, however if i click start again the other buttons get enabled suddenly.
So this way seems to work, only i need to press start twice, meaning i got 4 cards and the dealer 2.
Is there any way i can let it happen immediately or maybe there is some other way to disable/enable buttons using only PHP.
Thanks in advance!