php老虎机信用


php slot machine credits

嘿,我正在做一台老虎机,差不多完成了。我唯一需要的就是信用卡,所以它只会在信用卡上增加分数。就像如果我有100个学分,然后得到25个学分,我想说是125个学分。现在我不知道如何从之前的回合中获得积分
这就是我得到的:

            <?
    $tal = rand (1,3 ); {
    echo "<img src='css/billeder/enarmet$tal.gif' class=billed />"; 
    $tal2 = rand (1,3 ); 
    echo "<img src='css/billeder/enarmet$tal2.gif' class=billed />"; 
    $tal3 = rand (1,3 ); 
    echo "<img src='css/billeder/enarmet$tal3.gif' class=billed />"; }
    ?>
            </div>
            <div id="credits">
                <h3 id="credits2">CREDITS</h3>
                <h3 id="credits3"><?php 
                $credits=$_GET['credits'];
        if ($tal . $tal2 . $tal3 == 111){
            ($credits=($credits+100));              
        }
        if ($tal . $tal2 . $tal3 == 222){
            ($credits=($credits+50));                
        }
        if ($tal . $tal2 . $tal3 == 333){
            ($credits=($credits+25));               
        }
        echo $credits;
        ?></h3>
            </div>
        </div>
        <form action="index.php" method="POST">
            <input type="submit" value="SPIN" class="knap">
        </form> 
        <form action="cashout.php" method="POST">
            <input type="submit" value="CASH OUT" class="knap">
        </form>
    </div>

使用会话怎么样?使用从会话存储中存储和检索信用

session_start();
$credits = $_SESSION['credits'];

在脚本和的顶部

$_SESSION['credits'] = $credits;

底部。

这样,在页面加载之间将保留信用。

您可以删除以下行末尾的大括号,这是不需要的,请尝试。

<?
    $tal = rand (1,3 ); { // remove the open brace
    echo "<img src='css/billeder/enarmet$tal.gif' class=billed />"; 
...
echo "<img src='css/billeder/enarmet$tal3.gif' class=billed />"; } // remove the close brace
    ?>